Instructions to use Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24") model = AutoModelForCausalLM.from_pretrained("Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24", 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24
- SGLang
How to use Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24 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 "Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24" \ --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": "Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24", "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 "Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24" \ --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": "Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24 with Docker Model Runner:
docker model run hf.co/Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24
Генерирует рандомные символы
Приветствую @Crash3000
Насколько я вижу вы пытаетесь передать в обычный запрос текстом список ролей и контента.
Чтобы всё заработало корректно, необходимо передавать этот список messages=[{'role'...в метод: tokenizer.apply_chat_template(conversation=messages, tokenize=False, add_generation_prompt=True) после чего вы получите уже преобразованный список в правильный промпт в таком виде:
<s><|start_header_id|>system<|end_header_id|>
Your task is to answer the user's questions using only the information from the provided documents. Give two answers to each question: one with a list of relevant document identifiers and the second with the answer to the question itself, using documents with these identifiers.</s><|start_header_id|>documents<|end_header_id|>
[{"doc_id": 0, "title": "Глобальное потепление: ледники", "content": "За последние 50 лет объем ледников в мире уменьшился на 30%"}, {"doc_id": 1, "title": "Глобальное потепление: Уровень моря", "content": "Уровень мирового океана повысился на 20 см с 1880 года и продолжает расти на 3,3 мм в год"}]</s><|start_header_id|>user<|end_header_id|>
Глоабльное потепление</s><|start_header_id|>assistant<|end_header_id|>
P.s. Однако не рекомендую использовать подобный виджет (тем более для RAG), так как скорее всего у них автоматически всё сообщение пользователя попадает при обработке под роль user, что может быть причиной нестабильной работы. Лучше всего использовать vllm или написать свою предобработку и инференс через transformers как в примере тут
