hjd's picture
Update README.md
1a1f090 verified
|
raw
history blame
2 kB
metadata
license: apache-2.0
language:
  - en
  - zh
metrics:
  - accuracy
library_name: transformers
tags:
  - text2sql

text2sql-8b-instruct-v1

Summary

it is a natural language-to-SQL conversion model optimized specifically for Chinese and English users. It is based on the llama-3-chinese-8b-instruct-v3 model. We used the latest optimization algorithms to improve the performance of the model, especially in handling complex queries and multi-table joins.

Usage:

Please upgrade the transformers package to ensure it supports Llama3 models. The current version we are using is 4.41.2.

# Use a pipeline as a high-level helper
from transformers import pipeline
import torch
model_id = "xbrain/text2sql-8b-instruct-v1"


messages = [
    {"role": "system", 
     "content": "I want you to act as a SQL terminal in front of an example database, you need only to return the sql command to me.Below is an instruction that describes a task, Write a response that appropriately completes the request.\n\"\n##Instruction:\n database contains tables such as table_name_30. Table table_name_30 has columns such as nfl_team, draft_year."},
    {"role": "user", 
     "content": "###Input:\nIn 1978 what is the NFL team?\n\n###Response:"},
]
pipe_msg = pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device_map="auto",)

outputs = pipe_msg(
    messages,
    max_new_tokens=256,
)
print(outputs[0]["generated_text"][-1])

Ethical Considerations

While fine-tuned for text to sql, this model inherits the ethical considerations of the base Llama 3 model. Use responsibly and implement additional safeguards as needed for your application.

Availability

The model is available through:

For full details on responsible use, ethical considerations, and latest benchmarks, please refer to the official Llama 3 documentation.