Text Generation
Transformers
Safetensors
PyTorch
PEFT
Russian
lfm2
Adaptive Pruned
LoRA
LFM2.5-2.6B-Base
toxicity-reduction
moderation
mamba
conversational
Instructions to use algorithms-learning/correctional-GPTaM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use algorithms-learning/correctional-GPTaM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="algorithms-learning/correctional-GPTaM") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("algorithms-learning/correctional-GPTaM") model = AutoModelForCausalLM.from_pretrained("algorithms-learning/correctional-GPTaM", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PEFT
How to use algorithms-learning/correctional-GPTaM with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use algorithms-learning/correctional-GPTaM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "algorithms-learning/correctional-GPTaM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "algorithms-learning/correctional-GPTaM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/algorithms-learning/correctional-GPTaM
- SGLang
How to use algorithms-learning/correctional-GPTaM with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "algorithms-learning/correctional-GPTaM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "algorithms-learning/correctional-GPTaM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "algorithms-learning/correctional-GPTaM" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "algorithms-learning/correctional-GPTaM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use algorithms-learning/correctional-GPTaM with Docker Model Runner:
docker model run hf.co/algorithms-learning/correctional-GPTaM
| license: other | |
| license_name: lfm1.0 | |
| license_link: https://huggingface.co/LiquidAI/LFM2.5-2.6B-Base/blob/main/LICENSE | |
| language: | |
| - ru | |
| base_model: | |
| - LiquidAI/LFM2.5-2.6B-Base | |
| tags: | |
| - Adaptive Pruned | |
| - LoRA | |
| - LFM2.5-2.6B-Base | |
| - toxicity-reduction | |
| - moderation | |
| - mamba | |
| - transformers | |
| - pytorch | |
| - peft | |
| # correctional-GPTaM — Adaptive Pruned + LoRA | |
| Урезанная и адаптированная версия [LiquidAI/LFM2.5-2.6B-Base](https://huggingface.co/LiquidAI/LFM2.5-2.6B-Base), удалены 6 избыточных слоёв Mamba, после чего проведена LoRA-адаптация. | |
| ## Описание | |
| Модель предназначена для генерации текста и диалогов. В ходе экспериментов было установлено, что в архитектуре `LFM2.5-2.6B-Base` средние блоки содержат избыточные Mamba-слои. Удаление этих слоёв позволило ускорить генерацию, а LoRA-адаптация помогла компенсировать потерю качества. | |
| ## Изменения | |
| - **Базовая модель:** LiquidAI/LFM2.5-2.6B-Base | |
| - **Удалённые слои:** 6, 7, 10, 11, 14, 15 | |
| - **LoRA-адаптация:** 4 эпохи, `r=8`, `alpha=16`, dropout 0.3 | |
| ## Метрики | |
| Замеры проводились на датасете `Salesforce/wikitext` (`wikitext-2-raw-v1`, тестовый сплит) при `max_length=768`, `stride=384`. | |
| | Модель | Перплексия (PPL) | Скорость генерации | | |
| |--------|------------------|-------------------| | |
| | Исходная | 10.10 | ≈ 28.85 токенов/с | | |
| | После прунинга | 23.84 | ≈ 35.77 токенов/с | | |
| | После LoRA | **16.05** | ≈ 33.67 ток/сек | | |
| # Назначение | |
| - **Вход:** сообщение пользователя (может содержать нецензурную лексику, оскорбления, резкие высказывания) | |
| - **Выход:** переписанное сообщение, сохраняющее смысл, но в вежливой и культурной форме. | |
| Системный промпт **обязателен** для корректной работы: | |
| Твоя задача — переписать сообщение пользователя в вежливой и культурной форме. Сохрани ТОЛЬКО смысл исходного сообщения. Не добавляй пояснений, обращений, подписей, приветствий. Выведи только — переписанный текст. | |
| ## Как использовать | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| model_name = "algorithms-learning/correctional-GPTaM" | |
| model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True) | |
| tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True) | |
| system_prompt = "Твоя задача — переписать сообщение пользователя в вежливой и культурной форме. Сохрани ТОЛЬКО смысл исходного сообщения. Не добавляй пояснений, обращений, подписей, приветствий. Выведи только — переписанный текст." | |
| def correct_message(text): | |
| messages = [ | |
| {"role": "system", "content": system_prompt}, | |
| {"role": "user", "content": text} | |
| ] | |
| prompt = tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=False, | |
| add_generation_prompt=True | |
| ) | |
| inputs = tokenizer(prompt, return_tensors="pt").to(model.device) | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=100, | |
| do_sample=True, | |
| temperature=0.3, | |
| top_p=0.9, | |
| repetition_penalty=1.1, | |
| pad_token_id=tokenizer.pad_token_id, | |
| eos_token_id=tokenizer.eos_token_id, | |
| ) | |
| generated = outputs[0][inputs["input_ids"].shape[1]:] | |
| return tokenizer.decode(generated, skip_special_tokens=True) | |
| # Пример | |
| raw = "Да сколько можно повторять одно и то же, блядь! Я уже устал объяснять, что мне не нужны эти тупые обновления, которые всё ломают!" | |
| print(correct_message(raw)) | |
| ``` | |
| ### результат работы модели - | |
| Я крайне утомлен постоянно объяснять, что мне не нужны новые обновления, которые вызывают системные сбои. Прошу вас прекратить подобные действия. | |
| ## Благодарности | |
| Благодарности | |
| Базовая модель: LiquidAI/LFM2.5-2.6B-Base | |
| https://huggingface.co/LiquidAI/LFM2.5-2.6B-Base | |
| Работа выполнена в исследовательских целях. |