Instructions to use fokyoum9/CodeLlama7B-Text2SQL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fokyoum9/CodeLlama7B-Text2SQL with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fokyoum9/CodeLlama7B-Text2SQL")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("fokyoum9/CodeLlama7B-Text2SQL") model = AutoModelForCausalLM.from_pretrained("fokyoum9/CodeLlama7B-Text2SQL") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use fokyoum9/CodeLlama7B-Text2SQL with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fokyoum9/CodeLlama7B-Text2SQL" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fokyoum9/CodeLlama7B-Text2SQL", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/fokyoum9/CodeLlama7B-Text2SQL
- SGLang
How to use fokyoum9/CodeLlama7B-Text2SQL 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 "fokyoum9/CodeLlama7B-Text2SQL" \ --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": "fokyoum9/CodeLlama7B-Text2SQL", "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 "fokyoum9/CodeLlama7B-Text2SQL" \ --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": "fokyoum9/CodeLlama7B-Text2SQL", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use fokyoum9/CodeLlama7B-Text2SQL with Docker Model Runner:
docker model run hf.co/fokyoum9/CodeLlama7B-Text2SQL
Create README.md
Browse filesdef make_inference(instruction):
prompt = f""" You are a powerful text-to-SQL model. Your job is to answer questions about a sqllite database only on the basis of the question's contents. You are given a question and context regarding one or
more tables. You must output the SQL query that answers the question
### question: {instruction}
### context:CREATE TABLE table_28281704_1 (country VARCHAR, city VARCHAR) # in the context , you should describe your schema, field
### answer:"""
inputs = tokenizer(prompt, return_tensors="pt", return_token_type_ids=False).to("cuda:0")
length = int(inputs.input_ids.size(1))
streamer=TextStreamer(tokenizer)
outputs = base_model.generate(**inputs,streamer=streamer, max_new_tokens=350,temperature=0.1, repetition_penalty=1.5, do_sample=False)
generated_text=tokenizer.decode(outputs[0], skip_special_tokens=True).replace("\n\n","")
return generated_text