/ Модель

Характеристики

Контекст
2 048 токенов
Лицензия
MIT
Архитектура
codegen · dense
Базовая модель
codegen-350M-mono
Библиотека
transformers
Опубликована
16 сен 2025

stm32-hal-codegen

Генерация текстаТекст → текст3 профессии

Дообученная CodeGen-модель генерирует C-код STM32 HAL для периферии и прототипов прошивок.

81скачиваний за 30 дней2лайкавеса обновлены16 сен 2025

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Тесты пользователейпока нет

Никто ещё не опубликовал тест этой модели. Соберите бенчмарк из своих задач — результат появится здесь.

  1. Добавьте модель в бенчмарк

    Вместе с другими моделями категории «Текст» — сравнение идёт внутри одной категории.

  2. Опишите свои задачи

    Напишите запросы, при необходимости приложите файлы и эталонные ответы.

  3. Запустите и опубликуйте

    Модели ответят на каждую задачу, судья оценит ответы. Опубликованный результат появится на этой странице.

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

STM32 HAL Code Generator — специализированная авторегрессионная модель семейства CodeGen, дообученная на базе Salesforce/codegen-350M-mono для разработки прошивок под микроконтроллеры STM32. В модели 356,7 млн параметров, контекст — 2048 токенов; она принимает текстовые подсказки и генерирует код на C с использованием STM32 HAL. В README заявлено обучение на более чем 1000 примерах для семейств STM32F1, F4, L4, F0 и G4.

Модель предназначена для генерации начального кода и шаблонов периферии: GPIO, кнопок, ADC, UART, PWM и таймеров. Её можно использовать для прототипирования прошивок, подготовки учебных примеров и ускорения разработки проектов в STM32CubeIDE. Заявленные в README показатели качества не подтверждены независимой оценкой; результат следует проверить, скомпилировать и испытать на целевом оборудовании, особенно настройки тактирования, назначение выводов и сложные обработчики прерываний. Распространяется по лицензии MIT.

Сценарии применения

  • генерация кода управления GPIO и светодиодами на STM32
  • создание обработчиков кнопок с прерыванием и подавлением дребезга
  • подготовка примеров чтения ADC в режимах опроса и прерываний
  • генерация шаблонов UART-связи с заданной скоростью
  • создание PWM- и таймерного кода для прототипов STM32
  • подготовка учебных примеров STM32 HAL для STM32CubeIDE

Ограничения

Сгенерированный код требует проверки и испытаний на целевом оборудовании; конфигурации выводов и тактирования могут нуждаться в настройке. README отдельно рекомендует проверять сложные функции, включая DMA и обработчики прерываний.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

STM32 HAL Code Generator

English

1. Model Overview

The STM32 HAL Code Generator is a specialized large language model fine-tuned from Salesforce's CodeGen-350M-mono specifically for STM32 embedded systems development. The model contains 356.7 million parameters and has been trained on 1,000+ comprehensive STM32 HAL examples covering multiple microcontroller families and peripheral configurations.

This model is designed to generate production-ready STM32 HAL (Hardware Abstraction Layer) code for embedded systems developers, significantly accelerating firmware development and providing educational resources for STM32 learning.

2. Model Architecture

STM32 HAL CodeGenSpecifications
ArchitectureCodeGen (GPT-based)
Parameters356.7M
Base ModelSalesforce/codegen-350M-mono
Fine-tuning Dataset1,000+ STM32 examples
Context Length1,536 tokens
Training Duration30 minutes
Supported FamiliesSTM32F1, STM32F4, STM32L4, STM32F0, STM32G4
Vocabulary Size50,295

3. Supported Features

3.1 Peripheral Support

  • GPIO Control: LED control, digital I/O operations
  • Button Input: Digital input with debouncing and interrupt handling
  • ADC Operations: Analog-to-digital conversion in polling/interrupt modes
  • UART Communication: Serial communication with various baud rates
  • PWM Generation: Timer-based PWM for motor control and LED dimming
  • Timer Operations: Basic timing and interrupt-based operations

3.2 STM32 Family Support

  • STM32F1xx: Entry-level ARM Cortex-M3 microcontrollers
  • STM32F4xx: High-performance ARM Cortex-M4 microcontrollers
  • STM32L4xx: Ultra-low-power ARM Cortex-M4 microcontrollers
  • STM32F0xx: Entry-level ARM Cortex-M0 microcontrollers
  • STM32G4xx: Mixed-signal ARM Cortex-M4 microcontrollers

4. Benchmark Results

Test CategorySuccess RateCode Quality
LED Control95%Excellent
Button Input90%Very Good
ADC Reading95%Excellent
UART Communication92%Very Good
PWM Generation88%Very Good
Overall Performance83.3%Production-Ready

4.1 Code Quality Metrics

  • Compilation Rate: 95%+ (tested on STM32CubeIDE)
  • HAL Function Usage: Correct implementation in 98% of cases
  • GPIO Configuration: Proper pin initialization in 97% of outputs
  • System Integration: Complete projects with proper initialization
  • Code Structure: Industry-standard formatting and organization

5. Usage

5.1 Environment Setup

# Install dependencies
pip install transformers torch

# Download model
git lfs install
git clone https://huggingface.co/MuratKomurcu/stm32-hal-codegen

5.2 Quick Start

from transformers import AutoTokenizer, AutoModelForCausalLM

# Load model and tokenizer
model_name = "MuratKomurcu/stm32-hal-codegen"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

# Generate STM32 code
prompt = """// STM32_PROJECT: LED_CONTROL
// FAMILY: STM32F4
// TASK: Generate STM32F4 HAL LED blink code
// REQUIREMENT: Blink LED on PC13 every 1000ms

"""

inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
    inputs["input_ids"], 
    max_length=800, 
    temperature=0.8,
    do_sample=True,
    top_p=0.9,
    repetition_penalty=1.1
)

code = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(code)

5.3 Advanced Usage

5.3.1 Project-Specific Generation

# LED Control Example
led_prompt = """// STM32_PROJECT: LED_CONTROL
// FAMILY: STM32F4
// TASK: Generate multi-LED control code
// REQUIREMENT: Control 3 LEDs on PA5, PB0, PC13 with different patterns

"""

# UART Communication Example
uart_prompt = """// STM32_PROJECT: UART_COMM
// FAMILY: STM32F1
// TASK: Generate UART communication code
// REQUIREMENT: Setup UART1 at 115200 baud for sensor data transmission

"""

# ADC Reading Example
adc_prompt = """// STM32_PROJECT: ADC_READING
// FAMILY: STM32F4
// TASK: Generate multi-channel ADC code
// REQUIREMENT: Read analog values from PA0, PA1, PA2 in polling mode

"""

5.3.2 Prompt Format Guidelines

For optimal results, use this prompt structure:

// STM32_PROJECT: [LED_CONTROL|BUTTON_INPUT|ADC_READING|UART_COMM|PWM_GENERATION]
// FAMILY: [STM32F1|STM32F4|STM32L4|STM32F0|STM32G4] (optional)
// COMPLEXITY: [BASIC|INTERMEDIATE|ADVANCED] (optional)
// TASK: [Brief description of the task]
// REQUIREMENT: [Detailed technical requirements]

5.4 Integration with STM32CubeIDE

  1. Generate code using the model
  2. Copy the generated main.c content
  3. Replace the main function in your STM32CubeIDE project
  4. Compile and flash to your STM32 device

6. Example Outputs

6.1 LED Blink Example

#include "stm32f4xx_hal.h"

void SystemClock_Config(void);
static void MX_GPIO_Init(void);

int main(void)
{
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();

    while (1)
    {
        HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
        HAL_Delay(1000);
    }
}

static void MX_GPIO_Init(void)
{
    GPIO_InitTypeDef GPIO_InitStruct = {0};
    __HAL_RCC_GPIOC_CLK_ENABLE();
    
    GPIO_InitStruct.Pin = GPIO_PIN_13;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
}

6.2 UART Communication Example

#include "stm32f4xx_hal.h"
#include <string.h>

UART_HandleTypeDef huart1;

int main(void)
{
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();
    MX_USART1_UART_Init();

    char msg[] = "STM32 HAL UART Ready\r\n";
    
    while (1)
    {
        HAL_UART_Transmit(&huart1, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
        HAL_Delay(2000);
    }
}

7. Training Details

7.1 Dataset Composition

CategoryExamplesComplexity Levels
LED Control250Basic to Advanced
Button Input200Basic to Advanced
ADC Reading200Intermediate to Advanced
UART Communication200Intermediate to Advanced
PWM Generation150Advanced
Total1,000Multi-level

7.2 Training Configuration

  • Base Model: Salesforce/codegen-350M-mono
  • Training Epochs: 6
  • Batch Size: 12 (effective)
  • Learning Rate: 3e-5
  • Training Duration: 29 minutes 49 seconds
  • Final Training Loss: 0.0841
  • Final Validation Loss: 0.006074

7.3 Hardware Requirements

  • Minimum GPU: 8GB VRAM (RTX 3070/4060)
  • Recommended GPU: 16GB+ VRAM (RTX 4080/4090)
  • RAM: 16GB+ system memory
  • Storage: 10GB for model files

8. Limitations and Considerations

8.1 Current Limitations

  • Generated code should be reviewed before production deployment
  • May require minor adjustments for specific hardware configurations
  • Clock configuration may need fine-tuning for precise timing requirements
  • Advanced features like DMA and complex interrupt handlers need verification

8.2 Best Practices

  • Always compile and test generated code on actual hardware
  • Review GPIO pin assignments for your specific board
  • Verify clock settings match your system requirements
  • Test peripheral configurations with your hardware setup

9. Use Cases

9.1 Educational Applications

  • University Courses: Embedded systems and microcontroller programming
  • Bootcamps: Accelerated embedded development training
  • Self-Learning: STM32 HAL function reference and best practices
  • Code Examples: Learning proper STM32 coding patterns

9.2 Professional Development

  • Rapid Prototyping: Quick generation of boilerplate firmware code
  • Code Templates: Starting points for embedded projects
  • Documentation: HAL usage examples and implementation patterns
  • Team Training: Standardized coding practices across development teams

9.3 Research and Development

  • IoT Projects: Quick setup of sensor interfaces and communication
  • Academic Research: Embedded systems research acceleration
  • Proof of Concepts: Fast implementation of embedded system ideas
  • Hardware Testing: Quick firmware for hardware validation

10. Model Performance Analysis

10.1 Strengths

  • High Accuracy: 83.3% success rate on comprehensive tests
  • Fast Generation: Sub-second code generation
  • Multiple Families: Support for 5 STM32 product lines
  • Production Quality: Industry-standard code formatting
  • Comprehensive Coverage: Wide range of peripheral functions

10.2 Technical Achievements

  • Syntax Accuracy: 95%+ syntactically correct code
  • HAL Compliance: Proper STM32 HAL function usage
  • Complete Projects: Full main.c files with initialization
  • Best Practices: Following STM32 development guidelines
  • Scalable Architecture: Easy extension to new peripherals

11. Future Roadmap

11.1 Planned Enhancements

  • Extended Family Support: STM32H7, STM32WL, STM32U5 series
  • Advanced Peripherals: DMA, advanced timers, communication protocols
  • Real-time Features: RTOS integration and real-time applications
  • Optimization: Performance and power optimization suggestions
  • Testing Integration: Unit test generation for embedded code

11.2 Community Contributions

We welcome contributions from the embedded systems community:

  • Dataset Expansion: Submit high-quality STM32 examples
  • Bug Reports: Report incorrect code generation
  • Feature Requests: Suggest new peripheral support
  • Documentation: Improve usage examples and tutorials

12. Citation

If you use this model in your research, projects, or educational materials, please cite:

@model{stm32-hal-codegen-2025,
  title={STM32 HAL Code Generator: A Specialized Language Model for Embedded Systems},
  author={Murat Komurcu},
  year={2025},
  publisher={Hugging Face},
  url={https://huggingface.co/MuratKomurcu/stm32-hal-codegen}
}

13. License

This model is released under the MIT License. You are free to use, modify, and distribute this model for both commercial and non-commercial purposes.

13.1 Base Model License

This work is based on Salesforce's CodeGen model, which is licensed under the BSD-3-Clause License. We acknowledge and respect the original license terms.

13.2 Attribution

  • Base Model: Salesforce/codegen-350M-mono
  • Fine-tuning: Custom STM32 HAL dataset and training pipeline
  • Specialized Domain: STM32 embedded systems development

14. Support and Contact

14.1 Community Support

14.2 Professional Contact

For commercial licensing, enterprise support, or collaboration opportunities:

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers

Можно запустить

Подбираем GPU…

Класс архитектуры
CodeGenForCausalLM
Ревизия весов
1f216f7

0 моделей