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
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,4 +2,101 @@
|
|
| 2 |
license: other
|
| 3 |
license_name: lfm1.0
|
| 4 |
license_link: https://huggingface.co/LiquidAI/LFM2.5-2.6B-Base/blob/main/LICENSE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: other
|
| 3 |
license_name: lfm1.0
|
| 4 |
license_link: https://huggingface.co/LiquidAI/LFM2.5-2.6B-Base/blob/main/LICENSE
|
| 5 |
+
language:
|
| 6 |
+
- ru
|
| 7 |
+
base_model:
|
| 8 |
+
- LiquidAI/LFM2.5-2.6B-Base
|
| 9 |
+
tags:
|
| 10 |
+
- Adaptive Pruned
|
| 11 |
+
- LoRA
|
| 12 |
+
- LFM2.5-2.6B-Base
|
| 13 |
+
- toxicity-reduction
|
| 14 |
+
- moderation
|
| 15 |
+
- mamba
|
| 16 |
+
- transformers
|
| 17 |
+
- pytorch
|
| 18 |
+
- peft
|
| 19 |
---
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# correctional-GPTaM — Adaptive Pruned + LoRA
|
| 23 |
+
|
| 24 |
+
Урезанная и адаптированная версия [LiquidAI/LFM2.5-2.6B-Base](https://huggingface.co/LiquidAI/LFM2.5-2.6B-Base), удалены 6 избыточных слоёв Mamba, после чего проведена LoRA-адаптация.
|
| 25 |
+
|
| 26 |
+
## Описание
|
| 27 |
+
|
| 28 |
+
Модель предназначена для генерации текста и диалогов. В ходе экспериментов было установлено, что в архитектуре `LFM2.5-2.6B-Base` средние блоки содержат избыточные Mamba-слои. Удаление этих слоёв позволило ускорить генерацию, а LoRA-адаптация помогла компенсировать потерю качества.
|
| 29 |
+
|
| 30 |
+
## Изменения
|
| 31 |
+
|
| 32 |
+
- **Базовая модель:** LiquidAI/LFM2.5-2.6B-Base
|
| 33 |
+
- **Удалённые слои:** 6, 7, 10, 11, 14, 15
|
| 34 |
+
- **LoRA-адаптация:** 4 эпохи, `r=8`, `alpha=16`, dropout 0.3
|
| 35 |
+
|
| 36 |
+
## Метрики
|
| 37 |
+
|
| 38 |
+
Замеры проводились на датасете `Salesforce/wikitext` (`wikitext-2-raw-v1`, тестовый сплит) при `max_length=768`, `stride=384`.
|
| 39 |
+
|
| 40 |
+
| Модель | Перплексия (PPL) | Скорость генерации |
|
| 41 |
+
|--------|------------------|-------------------|
|
| 42 |
+
| Исходная | 10.10 | ≈ 28.85 токенов/с |
|
| 43 |
+
| После прунинга | 23.84 | ≈ 35.77 токенов/с |
|
| 44 |
+
| После LoRA | **16.05** | ≈ 33.67 ток/сек |
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
# Назначение
|
| 48 |
+
- **Вход:** сообщение пользователя (может содержать нецензурную лексику, оскорбления, резкие высказывания)
|
| 49 |
+
- **Выход:** переписанное сообщение, сохраняющее смысл, но в вежливой и культурной форме.
|
| 50 |
+
|
| 51 |
+
Системный промпт **обязателен** для корректной работы:
|
| 52 |
+
Твоя задача — переписать сообщение пользователя в вежливой и культурной форме. Сохрани ТОЛЬКО смысл исходного сообщения. Не добавляй пояснений, обращений, подписей, приветствий. Выведи только — переписанный текст.
|
| 53 |
+
|
| 54 |
+
## Как использовать
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 58 |
+
|
| 59 |
+
model_name = "algorithms-learning/correctional-GPTaM"
|
| 60 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
|
| 61 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 62 |
+
|
| 63 |
+
system_prompt = "Твоя задача — переписать сообщение пользователя в вежливой и культурной форме. Сохрани ТОЛЬКО смысл исходного сообщения. Не добавляй пояснений, обращений, подписей, приветствий. Выведи только — переписанный текст."
|
| 64 |
+
|
| 65 |
+
def correct_message(text):
|
| 66 |
+
messages = [
|
| 67 |
+
{"role": "system", "content": system_prompt},
|
| 68 |
+
{"role": "user", "content": text}
|
| 69 |
+
]
|
| 70 |
+
prompt = tokenizer.apply_chat_template(
|
| 71 |
+
messages,
|
| 72 |
+
tokenize=False,
|
| 73 |
+
add_generation_prompt=True
|
| 74 |
+
)
|
| 75 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 76 |
+
outputs = model.generate(
|
| 77 |
+
**inputs,
|
| 78 |
+
max_new_tokens=100,
|
| 79 |
+
do_sample=True,
|
| 80 |
+
temperature=0.3,
|
| 81 |
+
top_p=0.9,
|
| 82 |
+
repetition_penalty=1.1,
|
| 83 |
+
pad_token_id=tokenizer.pad_token_id,
|
| 84 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 85 |
+
)
|
| 86 |
+
generated = outputs[0][inputs["input_ids"].shape[1]:]
|
| 87 |
+
return tokenizer.decode(generated, skip_special_tokens=True)
|
| 88 |
+
|
| 89 |
+
# Пример
|
| 90 |
+
raw = "Да сколько можно повторять одно и то же, блядь! Я уже устал объяснять, что мне не нужны эти тупые обновления, которые всё ломают!"
|
| 91 |
+
print(correct_message(raw))
|
| 92 |
+
```
|
| 93 |
+
### результат работы модели -
|
| 94 |
+
Я крайне утомлен постоянно объяснять, что мне не нужны новые обновления, которые вызывают системные сбои. Прошу вас прекратить подобные действия.
|
| 95 |
+
|
| 96 |
+
## Благодарности
|
| 97 |
+
Благодарности
|
| 98 |
+
|
| 99 |
+
Базовая модель: LiquidAI/LFM2.5-2.6B-Base
|
| 100 |
+
https://huggingface.co/LiquidAI/LFM2.5-2.6B-Base
|
| 101 |
+
|
| 102 |
+
Р��бота выполнена в исследовательских целях.
|