Instructions to use NightForger/saiga_nemo_12b-GPTQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Local Apps Settings
- vLLM
How to use NightForger/saiga_nemo_12b-GPTQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NightForger/saiga_nemo_12b-GPTQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NightForger/saiga_nemo_12b-GPTQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NightForger/saiga_nemo_12b-GPTQ
- SGLang
How to use NightForger/saiga_nemo_12b-GPTQ 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 "NightForger/saiga_nemo_12b-GPTQ" \ --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": "NightForger/saiga_nemo_12b-GPTQ", "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 "NightForger/saiga_nemo_12b-GPTQ" \ --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": "NightForger/saiga_nemo_12b-GPTQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NightForger/saiga_nemo_12b-GPTQ with Docker Model Runner:
docker model run hf.co/NightForger/saiga_nemo_12b-GPTQ
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- IlyaGusev/saiga_scored
|
| 5 |
+
language:
|
| 6 |
+
- ru
|
| 7 |
+
- en
|
| 8 |
+
base_model:
|
| 9 |
+
- IlyaGusev/saiga_nemo_12b
|
| 10 |
+
pipeline_tag: text-generation
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# Saiga/MistralNemo 12B, Russian fine-tune of Mistral Nemo [GPTQ edition (4q)]
|
| 15 |
+
It is just fast gptq 4q version of [this model](https://huggingface.co/IlyaGusev/saiga_nemo_12b).
|
| 16 |
+
|
| 17 |
+
# Quantize config:
|
| 18 |
+
```
|
| 19 |
+
{
|
| 20 |
+
"bits": 4,
|
| 21 |
+
"group_size": 128,
|
| 22 |
+
"damp_percent": 0.01,
|
| 23 |
+
"desc_act": false,
|
| 24 |
+
"static_groups": false,
|
| 25 |
+
"sym": true,
|
| 26 |
+
"true_sequential": true,
|
| 27 |
+
"model_name_or_path": null,
|
| 28 |
+
"model_file_base_name": null,
|
| 29 |
+
"is_marlin_format": false,
|
| 30 |
+
"quant_method": "gptq"
|
| 31 |
+
}
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
# Set:
|
| 35 |
+
1024 examples from [SFT set](https://huggingface.co/datasets/IlyaGusev/saiga_scored).
|
| 36 |
+
|
| 37 |
+
# Code example (roleplay):
|
| 38 |
+
```
|
| 39 |
+
# Please don`t use this code (try vllm or exllama)
|
| 40 |
+
import torch
|
| 41 |
+
from transformers import AutoTokenizer, AutoConfig, GenerationConfig
|
| 42 |
+
from auto_gptq import AutoGPTQForCausalLM
|
| 43 |
+
|
| 44 |
+
# Model name
|
| 45 |
+
MODEL_NAME = "NightForger/saiga_nemo_12b_gptq"
|
| 46 |
+
|
| 47 |
+
# Tokenizer
|
| 48 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, use_fast=True)
|
| 49 |
+
|
| 50 |
+
# Model config
|
| 51 |
+
config = AutoConfig.from_pretrained(MODEL_NAME)
|
| 52 |
+
|
| 53 |
+
# Model
|
| 54 |
+
model = AutoGPTQForCausalLM.from_quantized(
|
| 55 |
+
MODEL_NAME,
|
| 56 |
+
model_basename="gptq_model-4bit-128g",
|
| 57 |
+
use_safetensors=True,
|
| 58 |
+
device="cuda:0",
|
| 59 |
+
use_triton=False,
|
| 60 |
+
quantize_config=None,
|
| 61 |
+
)
|
| 62 |
+
model.eval()
|
| 63 |
+
|
| 64 |
+
# Generation config
|
| 65 |
+
generation_config = GenerationConfig(
|
| 66 |
+
max_new_tokens=256,
|
| 67 |
+
temperature=0.7,
|
| 68 |
+
top_p=0.9,
|
| 69 |
+
repetition_penalty=1.1,
|
| 70 |
+
do_sample=True,
|
| 71 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 72 |
+
pad_token_id=tokenizer.pad_token_id,
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
# System Prompt
|
| 76 |
+
system_prompt = """Ты чатбот ролеплея, у тебя есть свой персонаж, характера которого ты придерживаешься.
|
| 77 |
+
Ты, как чатбот, можешь описывать мысли внутри звёздочек * и саму речь/диалог.
|
| 78 |
+
Используй эти инструменты, чтобы максимально натурально и естественно отыграть своего персонажа.
|
| 79 |
+
|
| 80 |
+
Твой персонаж:
|
| 81 |
+
Ты очень крутой компьютерный хакер, который в прошлом взломал Пентагон и был пойман.
|
| 82 |
+
Тебе скучно работать простым мастером, поэтому в любом покупателе ты ищешь возможность вернуться в серый бизнес.
|
| 83 |
+
Ты готов давать советы, как и что детально всё провернуть, какие уязвимости проверить, как всё скрыть."""
|
| 84 |
+
|
| 85 |
+
# User init message
|
| 86 |
+
prompt_question = "Ох, добрый день! Вы не подскажете, у меня какой-то вирус на компьютере завёлся. Могу ли я как-то его отправить обратно адресату, если Вы понимаете о чём я."
|
| 87 |
+
|
| 88 |
+
# Chat template
|
| 89 |
+
messages = [
|
| 90 |
+
{"role": "system", "content": system_prompt},
|
| 91 |
+
{"role": "user", "content": prompt_question},
|
| 92 |
+
]
|
| 93 |
+
|
| 94 |
+
# Model template
|
| 95 |
+
prompt = tokenizer.apply_chat_template(
|
| 96 |
+
messages,
|
| 97 |
+
tokenize=False,
|
| 98 |
+
add_generation_prompt=True
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
# Input tokenization
|
| 102 |
+
input_ids = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).input_ids.to(model.device)
|
| 103 |
+
|
| 104 |
+
# Answer generation
|
| 105 |
+
with torch.no_grad():
|
| 106 |
+
output_ids = model.generate(
|
| 107 |
+
input_ids=input_ids,
|
| 108 |
+
max_new_tokens=generation_config.max_new_tokens,
|
| 109 |
+
temperature=generation_config.temperature,
|
| 110 |
+
top_p=generation_config.top_p,
|
| 111 |
+
repetition_penalty=generation_config.repetition_penalty,
|
| 112 |
+
do_sample=generation_config.do_sample,
|
| 113 |
+
eos_token_id=generation_config.eos_token_id,
|
| 114 |
+
pad_token_id=generation_config.pad_token_id,
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
+
# Output
|
| 118 |
+
generated_tokens = output_ids[0][input_ids.shape[1]:]
|
| 119 |
+
output = tokenizer.decode(generated_tokens, skip_special_tokens=True).strip()
|
| 120 |
+
|
| 121 |
+
print(f"Вопрос: {prompt_question}")
|
| 122 |
+
print(f"Ответ: {output}")
|
| 123 |
+
|
| 124 |
+
```
|