Instructions to use Emma92/llama-2-7b-emma-1k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Emma92/llama-2-7b-emma-1k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Emma92/llama-2-7b-emma-1k", device_map="auto")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Emma92/llama-2-7b-emma-1k") model = AutoModelForCausalLM.from_pretrained("Emma92/llama-2-7b-emma-1k", device_map="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Emma92/llama-2-7b-emma-1k with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Emma92/llama-2-7b-emma-1k" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Emma92/llama-2-7b-emma-1k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Emma92/llama-2-7b-emma-1k
- SGLang
How to use Emma92/llama-2-7b-emma-1k 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 "Emma92/llama-2-7b-emma-1k" \ --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": "Emma92/llama-2-7b-emma-1k", "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 "Emma92/llama-2-7b-emma-1k" \ --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": "Emma92/llama-2-7b-emma-1k", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Emma92/llama-2-7b-emma-1k with Docker Model Runner:
docker model run hf.co/Emma92/llama-2-7b-emma-1k
💻 Colab
The model has been trained using google colab TPU GPU and high RAM!
The project is only for educational purposes.
# Install required libraries
!pip install transformers accelerate
import torch
import transformers
from transformers import AutoTokenizer
# Model and prompt information
model_name = "Emma92/llama-2-7b-emma-1k"
prompt = "Who is Immanuel Kant?"
# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Set up the text generation pipeline
pipeline = transformers.pipeline(
"text-generation",
model=model,
torch_dtype=torch.float16,
device_map="auto",
)
# Generate text sequences
sequences = generator(
f'<s>[INST] {prompt} [/INST]', # Include prompt in the input
do_sample=True,
top_k=10,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
max_length=200,
)
# Print generated sequences
for seq in sequences:
print(f"Result: {seq['generated_text']}")
Output
Result: <s>[INST] Who is Immanuel Kant? [/INST] Immanuel Kant was a German philosopher and one of the most influential thinkers in modern Western philosophy.Ъ He is best known for his work on ethics, metaphysics, epistemology and aesthetics, which has had a profound impact on the development of modern philosophy. He was born in Königsberg, Prussia in 1724 and died in the same city in 1804. Through his work, Kant established many of the foundational concepts of modern philosophy, and his ideas continue to influence philosophy and other fields to this day.
Some of Kant's most well-known ideas include:
1. Critique of Pure Reason: This is Kant's most famous work, in which he develops a comprehensive critique of reason and its limits. He argues that our understanding is shaped by the categories
- Downloads last month
- 12