Text Generation
Transformers
PyTorch
English
llama
english
sql
text2text-generation
text-generation-inference
Instructions to use MRNH/llama-2-7b-coder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MRNH/llama-2-7b-coder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MRNH/llama-2-7b-coder")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MRNH/llama-2-7b-coder") model = AutoModelForCausalLM.from_pretrained("MRNH/llama-2-7b-coder") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use MRNH/llama-2-7b-coder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MRNH/llama-2-7b-coder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MRNH/llama-2-7b-coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MRNH/llama-2-7b-coder
- SGLang
How to use MRNH/llama-2-7b-coder 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 "MRNH/llama-2-7b-coder" \ --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": "MRNH/llama-2-7b-coder", "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 "MRNH/llama-2-7b-coder" \ --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": "MRNH/llama-2-7b-coder", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MRNH/llama-2-7b-coder with Docker Model Runner:
docker model run hf.co/MRNH/llama-2-7b-coder
Update README.md
Browse files
README.md
CHANGED
|
@@ -14,27 +14,28 @@ This is a fine-tuned version of LLAMA2 trained (7b) on spider, sql-create-contex
|
|
| 14 |
|
| 15 |
To initialize the model:
|
| 16 |
|
| 17 |
-
|
|
|
|
| 18 |
load_in_4bit=use_4bit,
|
| 19 |
bnb_4bit_quant_type=bnb_4bit_quant_type,
|
| 20 |
bnb_4bit_compute_dtype=compute_dtype,
|
| 21 |
bnb_4bit_use_double_quant=use_nested_quant,
|
| 22 |
)
|
| 23 |
|
| 24 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 25 |
model_name,
|
| 26 |
quantization_config=bnb_config,
|
| 27 |
device_map=device_map,
|
| 28 |
trust_remote_code=True
|
| 29 |
)
|
| 30 |
-
|
| 31 |
|
| 32 |
Use the tokenizer:
|
| 33 |
|
| 34 |
|
| 35 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 36 |
-
tokenizer.pad_token = tokenizer.eos_token
|
| 37 |
-
tokenizer.padding_side = "right"
|
| 38 |
|
| 39 |
To get the prompt:
|
| 40 |
dataset = dataset.map(
|
|
|
|
| 14 |
|
| 15 |
To initialize the model:
|
| 16 |
|
| 17 |
+
|
| 18 |
+
bnb_config = BitsAndBytesConfig(
|
| 19 |
load_in_4bit=use_4bit,
|
| 20 |
bnb_4bit_quant_type=bnb_4bit_quant_type,
|
| 21 |
bnb_4bit_compute_dtype=compute_dtype,
|
| 22 |
bnb_4bit_use_double_quant=use_nested_quant,
|
| 23 |
)
|
| 24 |
|
| 25 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 26 |
model_name,
|
| 27 |
quantization_config=bnb_config,
|
| 28 |
device_map=device_map,
|
| 29 |
trust_remote_code=True
|
| 30 |
)
|
| 31 |
+
|
| 32 |
|
| 33 |
Use the tokenizer:
|
| 34 |
|
| 35 |
|
| 36 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 37 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 38 |
+
tokenizer.padding_side = "right"
|
| 39 |
|
| 40 |
To get the prompt:
|
| 41 |
dataset = dataset.map(
|