Instructions to use huanhkv/llama-2-7b-instruction-tuning_full with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use huanhkv/llama-2-7b-instruction-tuning_full with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="huanhkv/llama-2-7b-instruction-tuning_full")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("huanhkv/llama-2-7b-instruction-tuning_full") model = AutoModelForCausalLM.from_pretrained("huanhkv/llama-2-7b-instruction-tuning_full") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use huanhkv/llama-2-7b-instruction-tuning_full with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "huanhkv/llama-2-7b-instruction-tuning_full" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "huanhkv/llama-2-7b-instruction-tuning_full", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/huanhkv/llama-2-7b-instruction-tuning_full
- SGLang
How to use huanhkv/llama-2-7b-instruction-tuning_full 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 "huanhkv/llama-2-7b-instruction-tuning_full" \ --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": "huanhkv/llama-2-7b-instruction-tuning_full", "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 "huanhkv/llama-2-7b-instruction-tuning_full" \ --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": "huanhkv/llama-2-7b-instruction-tuning_full", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use huanhkv/llama-2-7b-instruction-tuning_full with Docker Model Runner:
docker model run hf.co/huanhkv/llama-2-7b-instruction-tuning_full
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
How it works
Base model is NousResearch/Llama-2-7b-chat-hf
How to use
import torch
import textwrap
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda" if torch.cuda.is_available() else "cpu"
EVAL_PROMPTS = [
"Hãy viết một phản hồi thích hợp cho chỉ dẫn dưới đây.\n\n### Instruction: Messi đã đạt bao nhiêu quả bóng vàng? \n\n### Response: ",
"Hãy viết một phản hồi thích hợp cho chỉ dẫn dưới đây.\n\n### Instruction: Thủ đô nào đông dân nhất châu Á? \n\n### Response: ",
"Hãy viết một phản hồi thích hợp cho chỉ dẫn dưới đây.\n\n### Instruction: Quốc gia nào có đường biển dài nhất? \n\n### Response: ",
]
def generate_eval(model: AutoModelForCausalLM, tokenizer: AutoTokenizer):
print("Starting Evaluation...")
model = model.to(device)
model.eval()
for eval_prompt in EVAL_PROMPTS:
batch = tokenizer(eval_prompt, return_tensors="pt").to(device)
with torch.cuda.amp.autocast():
output_tokens = model.generate(**batch, max_new_tokens=128)
print("\n\n", textwrap.fill(tokenizer.decode(output_tokens[0], skip_special_tokens=False)))
print("*"*100)
# Load the Lora model
model = AutoModelForCausalLM.from_pretrained("huanhkv/llama-2-7b-instruction-tuning_full")
tokenizer = AutoTokenizer.from_pretrained("huanhkv/llama-2-7b-instruction-tuning_full")
generate_eval(model, tokenizer)
The output should be:
<s> Hãy viết một phản hồi thích hợp cho chỉ dẫn dưới đây.
### Instruction: Messi đã đạt bao nhiêu quả bóng vàng?
### Response: 7</s>
******************************
<s> Hãy viết một phản hồi thích hợp cho chỉ dẫn dưới đây.
### Instruction: Thủ đô nào đông dân nhất châu Á?
### Response: Đông Đông Dương là thủ đô nhất châu Á về dân số.</s>
******************************
<s> Hãy viết một phản hồi thích hợp cho chỉ dẫn dưới đây.
### Instruction: Quốc gia nào có đường biển dài nhất?
### Response: Đường biển dài nhất trên thế giới là đường biển Ấn Độ Dương, dài khoảng 65.000 km.</s>
- Downloads last month
- 18