AIAT/Optimizer-datasetfinal
Viewer • Updated • 6.72k • 27
How to use AIAT/Optimizer-sealion2pandas with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="AIAT/Optimizer-sealion2pandas", trust_remote_code=True) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("AIAT/Optimizer-sealion2pandas", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("AIAT/Optimizer-sealion2pandas", trust_remote_code=True)How to use AIAT/Optimizer-sealion2pandas with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "AIAT/Optimizer-sealion2pandas"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "AIAT/Optimizer-sealion2pandas",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/AIAT/Optimizer-sealion2pandas
How to use AIAT/Optimizer-sealion2pandas with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "AIAT/Optimizer-sealion2pandas" \
--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": "AIAT/Optimizer-sealion2pandas",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "AIAT/Optimizer-sealion2pandas" \
--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": "AIAT/Optimizer-sealion2pandas",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use AIAT/Optimizer-sealion2pandas with Docker Model Runner:
docker model run hf.co/AIAT/Optimizer-sealion2pandas
fine-tuned from sea-lion-7b-instruct with question-pandas expression pairs.
from transformers import AutoModelForCausalLM, AutoTokenizer
import pandas as pd
tokenizer = AutoTokenizer.from_pretrained("AIAT/Optimizer-sealion2pandas", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("AIAT/Optimizer-sealion2pandas", trust_remote_code=True)
df = pd.read_csv("Your csv..")
prompt_template = "### USER:\n{human_prompt}\n\n### RESPONSE:\n"
prompt = """\
You are working with a pandas dataframe in Python.
The name of the dataframe is `df`.
This is the result of `print(df.head())`:
{df_str}
Follow these instructions:
1. Convert the query to executable Python code using Pandas.
2. The final line of code should be a Python expression that can be called with the `eval()` function.
3. The code should represent a solution to the query.
4. PRINT ONLY THE EXPRESSION.
5. Do not quote the expression.
Query: {query_str} """
def create_prompt(query_str, df):
text = prompt.format(df_str=str(df.head()), query_str=query_str)
text = prompt_template.format(human_prompt=text)
return text
full_prompt = create_prompt("Find test ?", df)
tokens = tokenizer(full_prompt, return_tensors="pt")
output = model.generate(tokens["input_ids"], max_new_tokens=20, eos_token_id=tokenizer.eos_token_id)
print(tokenizer.decode(output[0], skip_special_tokens=True))
Base model
aisingapore/SEA-LION-v1-7B