Text Generation
Transformers
Safetensors
Persian
llama
text-generation-inference
8-bit precision
bitsandbytes
Instructions to use Neurai/NeuraLlama7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Neurai/NeuraLlama7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Neurai/NeuraLlama7b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Neurai/NeuraLlama7b") model = AutoModelForCausalLM.from_pretrained("Neurai/NeuraLlama7b") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Neurai/NeuraLlama7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Neurai/NeuraLlama7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Neurai/NeuraLlama7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Neurai/NeuraLlama7b
- SGLang
How to use Neurai/NeuraLlama7b 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 "Neurai/NeuraLlama7b" \ --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": "Neurai/NeuraLlama7b", "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 "Neurai/NeuraLlama7b" \ --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": "Neurai/NeuraLlama7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Neurai/NeuraLlama7b with Docker Model Runner:
docker model run hf.co/Neurai/NeuraLlama7b
Installing Libraries
Make sure these libraries are installed correctly.
pip install -q sentencepiecepip install -q transformerspip install -q acceleratepip install --upgrade -q bitsandbytes
import torch
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
model_path = "Neurai/llama7b"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
"Neurai/llama7b",
# load_in_8bit=True,
torch_dtype=torch.bfloat16,
low_cpu_mem_usage=True,
device_map="auto",
)
model.eval()
print('model loaded')
SYS_PROMPT = "زرافه چند سال عمر میکند؟"
def response_generate(input_prompt):
input_ids = tokenizer(input_prompt, return_tensors="pt")
outputs = model.generate(
inputs=input_ids["input_ids"].to("cuda"),
attention_mask=input_ids["attention_mask"].to("cuda"),
do_sample=True,
temperature=0.3,
top_k=50,
top_p=0.9,
max_new_tokens=512,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id
)
response = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
return response
print(response_generate(f"{SYS_PROMPT}"))
- Downloads last month
- 8