Instructions to use nguyenthanhdo/noprob_model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nguyenthanhdo/noprob_model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nguyenthanhdo/noprob_model")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nguyenthanhdo/noprob_model") model = AutoModelForCausalLM.from_pretrained("nguyenthanhdo/noprob_model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nguyenthanhdo/noprob_model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nguyenthanhdo/noprob_model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nguyenthanhdo/noprob_model", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/nguyenthanhdo/noprob_model
- SGLang
How to use nguyenthanhdo/noprob_model 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 "nguyenthanhdo/noprob_model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nguyenthanhdo/noprob_model", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "nguyenthanhdo/noprob_model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nguyenthanhdo/noprob_model", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use nguyenthanhdo/noprob_model with Docker Model Runner:
docker model run hf.co/nguyenthanhdo/noprob_model
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
This model is specialized for question answering with context in Vietnamese. How to use:
import torch
import os
from transformers import LlamaForCausalLM, LlamaTokenizer, LlamaConfig
from transformers import GenerationConfig, TextStreamer
from peft import PeftModel
from axolotl.prompters import AlpacaPrompter, PromptStyle
### Load model
torch_dtype = torch.bfloat16
device_map = {"": int(os.environ.get("CUDA_DEVICE") or 0)}
model_id = "nguyenthanhdo/noprob_model"
tokenizer = LlamaTokenizer.from_pretrained(model_id)
model = LlamaForCausalLM.from_pretrained(
model_id,
config=LlamaConfig.from_pretrained(model_id),
device_map=device_map,
torch_dtype=torch_dtype
)
### Build prompt
prompter = AlpacaPrompter(prompt_style=PromptStyle.INSTRUCT.value)
# instruction = "Provide short and concise answer. The answer should be straight and only provides explanation when needed." # Another instruction to test
instruction = 'You are an AI assistant. Provide a detailed answer so user don’t need to search outside to understand the answer.'
question = input()
context = input()
input = f"""Dựa vào bài viết dưới đây, trả lời câu hỏi phía dưới:\n{context}\n\nCâu hỏi: {question}"""
prompt = prompter.build_prompt(instruction=instruction, input=input, output="").__next__()
### Generate answer
input_ids = tokenizer(prompt, return_tensors="pt")["input_ids"].to(model.device)
model.eval()
with torch.no_grad():
generation_config = GenerationConfig(
repetition_penalty=1.13,
max_new_tokens=max_new_tokens,
temperature=0.2,
top_p=0.95,
top_k=20,
pad_token_id=tokenizer.pad_token_id,
do_sample=True,
use_cache=True,
return_dict_in_generate=True,
output_attentions=False,
output_hidden_states=False,
output_scores=False,
)
streamer = TextStreamer(tokenizer, skip_prompt=True)
generated = model.generate(
inputs=input_ids,
generation_config=generation_config,
streamer=streamer,
)
- Downloads last month
- 17