Text Generation
Transformers
Safetensors
mistral
text-generation-inference
4-bit precision
bitsandbytes
Instructions to use jonruida/model-IC with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jonruida/model-IC with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jonruida/model-IC")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jonruida/model-IC") model = AutoModelForCausalLM.from_pretrained("jonruida/model-IC") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use jonruida/model-IC with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jonruida/model-IC" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jonruida/model-IC", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/jonruida/model-IC
- SGLang
How to use jonruida/model-IC 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 "jonruida/model-IC" \ --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": "jonruida/model-IC", "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 "jonruida/model-IC" \ --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": "jonruida/model-IC", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use jonruida/model-IC with Docker Model Runner:
docker model run hf.co/jonruida/model-IC
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME"j
|
| 3 |
+
repo_id = "jonruida/model-IC"
|
| 4 |
+
|
| 5 |
+
query_pipeline = transformers.pipeline(
|
| 6 |
+
"text-generation",
|
| 7 |
+
model=model,
|
| 8 |
+
tokenizer=tokenizer,
|
| 9 |
+
torch_dtype=torch.float16,
|
| 10 |
+
device_map="auto", max_new_tokens=200)
|
| 11 |
+
|
| 12 |
+
def test_rag(pipeline, input_text):
|
| 13 |
+
docs = chroma_db/chroma.sqlite3.similarity_search_with_score(query)
|
| 14 |
+
context = []
|
| 15 |
+
for doc,score in docs:
|
| 16 |
+
if(score<7):
|
| 17 |
+
doc_details = doc.to_json()['kwargs']
|
| 18 |
+
context.append( doc_details['page_content'])
|
| 19 |
+
if(len(context)!=0):
|
| 20 |
+
messages = [{"role": "user", "content": "Bas谩ndote en la siguiente informaci贸n: " + "\n".join(context) + "\n Responde en castellano a la pregunta: " + query}]
|
| 21 |
+
prompt = pipeline.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 22 |
+
outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
| 23 |
+
answer = outputs[0]["generated_text"]
|
| 24 |
+
return answer[answer.rfind("[/INST]")+8:],docs
|
| 25 |
+
else:
|
| 26 |
+
return "No tengo informaci贸n para responder a esta pregunta",docs
|
| 27 |
+
|