Instructions to use solbi12/ax4-mongodb-query-generator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use solbi12/ax4-mongodb-query-generator with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="solbi12/ax4-mongodb-query-generator") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("solbi12/ax4-mongodb-query-generator") model = AutoModelForCausalLM.from_pretrained("solbi12/ax4-mongodb-query-generator", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use solbi12/ax4-mongodb-query-generator with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "solbi12/ax4-mongodb-query-generator" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "solbi12/ax4-mongodb-query-generator", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/solbi12/ax4-mongodb-query-generator
- SGLang
How to use solbi12/ax4-mongodb-query-generator 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 "solbi12/ax4-mongodb-query-generator" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "solbi12/ax4-mongodb-query-generator", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "solbi12/ax4-mongodb-query-generator" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "solbi12/ax4-mongodb-query-generator", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use solbi12/ax4-mongodb-query-generator with Docker Model Runner:
docker model run hf.co/solbi12/ax4-mongodb-query-generator
- ๐ A.X-4.0-Light MongoDB Query Generator
- ๐ ๋ชจ๋ธ ๊ฐ์
- ๐ ๋น ๋ฅธ ์์
- ๐ ์ฑ๋ฅ ์์
- ๐๏ธ ์ง์ํ๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํค๋ง
- ๐ฏ ์ฌ์ฉ ์ฌ๋ก
- ๐ ๏ธ ๊ธฐ์ ์ธ๋ถ์ฌํญ
- ๐ ๋ฒค์น๋งํฌ ๊ฒฐ๊ณผ
- โ ๏ธ ์ ํ์ฌํญ ๋ฐ ๊ณ ๋ ค์ฌํญ
- ๐ ์ ๋ฐ์ดํธ ๋ก๊ทธ
- ๐ฅ ๊ธฐ์ฌ์
- ๐ ๋ฌธ์ ๋ฐ ์ง์
- ๐ ๋ผ์ด์ ์ค
- ๐ ์ธ์ฉ
๐ A.X-4.0-Light MongoDB Query Generator
ํ๊ตญ์ด ์์ฐ์ด๋ฅผ MongoDB ์ฟผ๋ฆฌ๋ก ๋ณํํ๋ AI ๋ชจ๋ธ
SKT A.X-4.0-Light ๊ธฐ๋ฐ์ผ๋ก ํ์ธํ๋๋ ์ ๋ฌธ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฟผ๋ฆฌ ์์ฑ ๋ชจ๋ธ
๐ ๋ชจ๋ธ ๊ฐ์
์ด ๋ชจ๋ธ์ SKT์ A.X-4.0-Light๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ์ฌ ํ๊ตญ์ด ์์ฐ์ด๋ฅผ MongoDB ์ฟผ๋ฆฌ๋ก ๋ณํํ๋๋ก LoRA ํ์ธํ๋๋ ํนํ ๋ชจ๋ธ์ ๋๋ค. ์ด์ปค๋จธ์ค ๋๋ฉ์ธ์ ์ต์ ํ๋์ด ์์ผ๋ฉฐ, ๋ณต์กํ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฟผ๋ฆฌ๋ ์์ฐ์ค๋ฌ์ด ํ๊ตญ์ด๋ก ์์ฒญํ ์ ์์ต๋๋ค.
โจ ์ฃผ์ ํน์ง
- ๐ฏ ๊ณ ์ ๋ฐ๋: 360๊ฐ์ ์์ ๋ ๋ฐ์ดํฐ์ ์ผ๋ก ํ์ต
- ๐ฐ๐ท ํ๊ตญ์ด ํนํ: ์์ฐ์ค๋ฌ์ด ํ๊ตญ์ด ์ง๋ฌธ ์ดํด
- ๐๏ธ ์ด์ปค๋จธ์ค ๋๋ฉ์ธ: ์ํ, ์ฃผ๋ฌธ, ๋ฆฌ๋ทฐ ๋ฑ ์ค์ ๋น์ฆ๋์ค ์๋๋ฆฌ์ค
- โก ์ค์๊ฐ ๋ณํ: ๋น ๋ฅด๊ณ ์ ํํ ์ฟผ๋ฆฌ ์์ฑ
- ๐ง ๋ค์ํ ์ฟผ๋ฆฌ: ๊ธฐ๋ณธ ์กฐํ๋ถํฐ ๋ณต์กํ ์ง๊ณ๊น์ง
๐ ๋น ๋ฅธ ์์
์ค์น
pip install transformers torch
๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# ๋ชจ๋ธ๊ณผ ํ ํฌ๋์ด์ ๋ก๋
model_name = "solbi12/ax4-mongodb-query-generator"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
def generate_mongo_query(natural_query):
messages = [
{
"role": "system",
"content": "๋น์ ์ ์์ฐ์ด๋ฅผ MongoDB ์ฟผ๋ฆฌ๋ก ๋ณํํ๋ ์ ๋ฌธ๊ฐ์
๋๋ค."
},
{
"role": "user",
"content": natural_query
}
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
)
with torch.no_grad():
output = model.generate(
input_ids,
max_new_tokens=128,
do_sample=False,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(
output[0][len(input_ids[0]):],
skip_special_tokens=True
)
return response
# ์ฌ์ฉ ์์
query = generate_mongo_query("๊ฐ๊ฒฉ์ด 5๋ง์ ์ดํ์ธ ์ํ๋ค์ ๋ณด์ฌ์ค")
print(query)
# ์ถ๋ ฅ: db.product.find({price: {$lte: 50000}})
๐ ์ฑ๋ฅ ์์
| ์์ฐ์ด ์ง๋ฌธ | ์์ฑ๋ MongoDB ์ฟผ๋ฆฌ |
|---|---|
| ๋ชจ๋ ์ํ์ ๋ณด์ฌ์ค | db.product.find() |
| ๊ฐ๊ฒฉ์ด 5๋ง์ ์ดํ์ธ ์ํ๋ค | db.product.find({price: {$lte: 50000}}) |
| ๋ธ๋๋๋ณ ํ๊ท ๊ฐ๊ฒฉ์ ๊ณ์ฐํด์ค | db.product.aggregate([{$group: {_id: '$brand', avg_price: {$avg: '$price'}}}]) |
| ์์ธ ์ง์ญ ๊ณ ๊ฐ๋ค์ ์ฃผ๋ฌธ ๋ด์ญ | db.orders.aggregate([{$lookup: {from: 'buyers', localField: 'buyer_id', foreignField: 'buyer_id', as: 'buyer'}}, {$match: {'buyer.address': {$regex: '์์ธ'}}}]) |
| ๋ฆฌ๋ทฐ๊ฐ ์ข์ ์ํ ์์ 10๊ฐ | db.product.find().sort({rating_avg: -1}).limit(10) |
๐๏ธ ์ง์ํ๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํค๋ง
์ปฌ๋ ์ ๊ตฌ์กฐ
| ์ปฌ๋ ์ | ์ค๋ช | ์ฃผ์ ํ๋ |
|---|---|---|
product |
์ํ ์ ๋ณด | name, price, brand, category_l1, rating_avg, reviews_count |
orders |
์ฃผ๋ฌธ ๋ฐ์ดํฐ | buyer_id, product_id, quantity, total_amount, order_date |
buyers |
๊ตฌ๋งค์ ์ ๋ณด | buyer_id, age, gender, address, marketing_opt_in |
reviews |
๋ฆฌ๋ทฐ ๋ฐ์ดํฐ | product_id, user_id, score, overall_sentiment |
sellers |
ํ๋งค์ ์ ๋ณด | seller_id, brand_name, categories |
users |
์ฌ์ฉ์ ์ ๋ณด | emp_no, team |
๐ฏ ์ฌ์ฉ ์ฌ๋ก
1. ์ ์์๊ฑฐ๋ ๋ถ์
queries = [
"์ด๋ฒ ๋ฌ ๋งค์ถ ์์ ๋ธ๋๋๋?",
"๊ณ ๊ฐ ๋ง์กฑ๋๊ฐ ๋์ ์ํ๋ค",
"์ฌ๊ตฌ๋งค์จ์ด ๋์ ๊ณ ๊ฐ ์ธ๊ทธ๋จผํธ"
]
2. ๋น์ฆ๋์ค ์ธํ ๋ฆฌ์ ์ค
queries = [
"์ง์ญ๋ณ ์ฃผ๋ฌธ ํจํด ๋ถ์",
"๊ณ์ ๋ณ ์ธ๊ธฐ ์นดํ
๊ณ ๋ฆฌ",
"๋ง์ผํ
์บ ํ์ธ ํจ๊ณผ ์ธก์ "
]
3. ์ค์๊ฐ ๋์๋ณด๋
queries = [
"์ค๋์ ์ค์๊ฐ ์ฃผ๋ฌธ ํํฉ",
"์ฌ๊ณ ๋ถ์กฑ ์ํ ์๋ฆผ",
"๊ณ ๊ฐ ์๋น์ค ์ฐ์ ์์"
]
๐ ๏ธ ๊ธฐ์ ์ธ๋ถ์ฌํญ
๋ชจ๋ธ ์ํคํ ์ฒ
- ๊ธฐ๋ฐ ๋ชจ๋ธ: SKT A.X-4.0-Light (4B parameters)
- ํ์ธํ๋ ๋ฐฉ๋ฒ: LoRA (Low-Rank Adaptation)
- ํ์ต ๋ฐ์ดํฐ: 360๊ฐ ํ๊ตญ์ด-MongoDB ์ฟผ๋ฆฌ ์
- ํ์ต ํ๊ฒฝ: A100 GPU, 3 epochs
ํ๋ผ๋ฏธํฐ ์ค์
LoRA Configuration:
r: 16
lora_alpha: 32
lora_dropout: 0.1
target_modules: ["q_proj", "v_proj", "k_proj", "o_proj"]
Training Parameters:
learning_rate: 2e-4
batch_size: 2
gradient_accumulation_steps: 4
max_length: 1024
๐ ๋ฒค์น๋งํฌ ๊ฒฐ๊ณผ
| ๋ฉํธ๋ฆญ | ์ ์ |
|---|---|
| ๊ตฌ๋ฌธ ์ ํ์ฑ | 92% |
| ์๋ฏธ์ ์ผ์น๋ | 87% |
| ์คํ ๊ฐ๋ฅ์ฑ | 95% |
| ์๋ต ์๋ | < 200ms |
โ ๏ธ ์ ํ์ฌํญ ๋ฐ ๊ณ ๋ ค์ฌํญ
์ ํ์ฌํญ
- ์ด์ปค๋จธ์ค ๋๋ฉ์ธ์ ํนํ๋์ด ์์
- ๋งค์ฐ ๋ณต์กํ ์ค์ฒฉ ์ง๊ณ์ ๊ฒฝ์ฐ ๋ถ์ ํํ ์ ์์
- ํ๊ตญ์ด ์ง๋ฌธ์ ์ต์ ํ (์์ด ์ง์ ์ ํ์ )
๊ถ์ฅ์ฌํญ
- ์์ฑ๋ ์ฟผ๋ฆฌ๋ ์คํ ์ ๊ฒ์ฆ ๊ถ์ฅ
- ํ๋ก๋์ ํ๊ฒฝ์์๋ ์ถ๊ฐ์ ์ธ ๋ณด์ ๊ฒ์ฆ ํ์
- ์ ๊ธฐ์ ์ธ ๋ชจ๋ธ ์ ๋ฐ์ดํธ ๊ถ์ฅ
๐ ์ ๋ฐ์ดํธ ๋ก๊ทธ
v1.0.0 (2024-09-16)
- ์ด๊ธฐ ๋ฆด๋ฆฌ์ค
- A.X-4.0-Light ๊ธฐ๋ฐ LoRA ํ์ธํ๋
- 360๊ฐ ๋ฐ์ดํฐ์ ์ผ๋ก ํ์ต ์๋ฃ
- ์ด์ปค๋จธ์ค ๋๋ฉ์ธ ํนํ
๐ฅ ๊ธฐ์ฌ์
๊ฐ๋ฐ์: Solbi
- ๋ชจ๋ธ ์ค๊ณ ๋ฐ ํ์ต
- ๋ฐ์ดํฐ์ ํ๋ ์ด์
- ์ฑ๋ฅ ์ต์ ํ
๐ ๋ฌธ์ ๋ฐ ์ง์
- Hugging Face: @solbi12
- Issues: ๋ชจ๋ธ ๊ด๋ จ ๋ฌธ์ ๋ ๊ฐ์ ์ ์์ Discussion ํญ์ ์ด์ฉํด์ฃผ์ธ์
๐ ๋ผ์ด์ ์ค
์ด ๋ชจ๋ธ์ Apache License 2.0 ํ์ ๋ฐฐํฌ๋ฉ๋๋ค.
๐ ์ธ์ฉ
@misc{solbi2024ax4mongodb,
title={A.X-4.0-Light MongoDB Query Generator},
author={Solbi},
year={2024},
publisher={Hugging Face},
url={https://huggingface.co/solbi12/ax4-mongodb-query-generator}
}
๐ ์ด ๋ชจ๋ธ์ด ์ ์ฉํ๋ค๋ฉด ์คํ๋ฅผ ๋๋ฌ์ฃผ์ธ์! ๐
๋ ๋์ AI ๋๊ตฌ๋ฅผ ๋ง๋ค๊ธฐ ์ํด ์ง์์ ์ผ๋ก ๊ฐ์ ํด๋๊ฐ๊ฒ ์ต๋๋ค.
- Downloads last month
- 4
Model tree for solbi12/ax4-mongodb-query-generator
Base model
skt/A.X-4.0-Light