Instructions to use PyThaGo/LLMLit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use PyThaGo/LLMLit with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="PyThaGo/LLMLit", filename="LLMLit-0.2-8B-Instruct.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use PyThaGo/LLMLit with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf PyThaGo/LLMLit # Run inference directly in the terminal: llama-cli -hf PyThaGo/LLMLit
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf PyThaGo/LLMLit # Run inference directly in the terminal: llama-cli -hf PyThaGo/LLMLit
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf PyThaGo/LLMLit # Run inference directly in the terminal: ./llama-cli -hf PyThaGo/LLMLit
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf PyThaGo/LLMLit # Run inference directly in the terminal: ./build/bin/llama-cli -hf PyThaGo/LLMLit
Use Docker
docker model run hf.co/PyThaGo/LLMLit
- LM Studio
- Jan
- Ollama
How to use PyThaGo/LLMLit with Ollama:
ollama run hf.co/PyThaGo/LLMLit
- Unsloth Studio new
How to use PyThaGo/LLMLit with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for PyThaGo/LLMLit to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for PyThaGo/LLMLit to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for PyThaGo/LLMLit to start chatting
- Pi new
How to use PyThaGo/LLMLit with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf PyThaGo/LLMLit
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "PyThaGo/LLMLit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use PyThaGo/LLMLit with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf PyThaGo/LLMLit
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default PyThaGo/LLMLit
Run Hermes
hermes
- Docker Model Runner
How to use PyThaGo/LLMLit with Docker Model Runner:
docker model run hf.co/PyThaGo/LLMLit
- Lemonade
How to use PyThaGo/LLMLit with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull PyThaGo/LLMLit
Run and chat with the model
lemonade run user.LLMLit-{{QUANT_TAG}}List all available models
lemonade list
Cristian Sas commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -336,6 +336,127 @@ Exemple de cod și șabloane utile 📝
|
|
| 336 |
🌍 Rămâi conectat pentru a descoperi toate aceste resurse care te vor ajuta să îți duci proiectele la următorul nivel!
|
| 337 |
|
| 338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
Așteptăm cu nerăbdare să lucrăm împreună și să facem pași mari în dezvoltarea AI-ului! 🌍✨
|
| 340 |
|
| 341 |

|
|
|
|
| 336 |
🌍 Rămâi conectat pentru a descoperi toate aceste resurse care te vor ajuta să îți duci proiectele la următorul nivel!
|
| 337 |
|
| 338 |
|
| 339 |
+
|
| 340 |
+
|
| 341 |
+
**Retrieval-Augmented Generation (RAG)** folosind modelul **LLMLit** disponibil pe Hugging Face. RAG combină căutarea informațiilor relevante cu generarea de texte pentru a produce răspunsuri mai precise. Vom utiliza Hugging Face pentru a integra acest model și vom folosi o bază de date externă pentru a face interogări și a îmbogăți răspunsurile generate de modelul LLMLit.
|
| 342 |
+
|
| 343 |
+
### **Pași pentru implementarea RAG cu LLMLit pe Hugging Face 🚀**
|
| 344 |
+
|
| 345 |
+
#### 1. **Instalarea pachetelor necesare 🛠️**
|
| 346 |
+
|
| 347 |
+
În primul rând, trebuie să instalezi librăriile necesare pentru a lucra cu **Hugging Face** și **LLMLit**. Poți face acest lucru folosind pip:
|
| 348 |
+
|
| 349 |
+
```bash
|
| 350 |
+
pip install transformers datasets faiss-cpu
|
| 351 |
+
```
|
| 352 |
+
|
| 353 |
+
- `transformers` este pachetul care ne permite să interacționăm cu modelele de la Hugging Face.
|
| 354 |
+
- `datasets` ne ajută să gestionăm datele externe pentru căutare.
|
| 355 |
+
- `faiss-cpu` este opțional, dar îl recomandăm pentru căutarea vectorială rapidă a documentelor.
|
| 356 |
+
|
| 357 |
+
#### 2. **Încărcarea modelului LLMLit de pe Hugging Face 🔄**
|
| 358 |
+
|
| 359 |
+
Acum, putem încarcă modelul **LLMLit** folosind Hugging Face:
|
| 360 |
+
|
| 361 |
+
```python
|
| 362 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 363 |
+
|
| 364 |
+
# Încărcăm modelul LLMLit și tokenizer-ul
|
| 365 |
+
tokenizer = AutoTokenizer.from_pretrained("LLMLit/LLMLit")
|
| 366 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("LLMLit/LLMLit")
|
| 367 |
+
```
|
| 368 |
+
|
| 369 |
+
#### 3. **Configurarea bazei de date de documente 🔍**
|
| 370 |
+
|
| 371 |
+
Pentru a folosi RAG, avem nevoie de o sursă externă de documente pentru a recupera informațiile relevante. În exemplul de față, vom folosi **FAISS** pentru căutarea rapidă a documentelor. Începe prin a crea un index FAISS:
|
| 372 |
+
|
| 373 |
+
```python
|
| 374 |
+
import faiss
|
| 375 |
+
import numpy as np
|
| 376 |
+
|
| 377 |
+
# Crearea unui set de documente fictive
|
| 378 |
+
documents = [
|
| 379 |
+
"LLMLit este un model puternic de procesare a limbajului natural.",
|
| 380 |
+
"RAG combină generarea de texte cu căutarea de informații externe.",
|
| 381 |
+
"Hugging Face oferă o platformă excelentă pentru modelele AI.",
|
| 382 |
+
"FAISS este un tool de căutare vectorială rapidă pentru baze de date mari."
|
| 383 |
+
]
|
| 384 |
+
|
| 385 |
+
# Tokenizare și crearea vectorilor pentru documente
|
| 386 |
+
embedding_model = AutoModelForSeq2SeqLM.from_pretrained("sentence-transformers/all-MiniLM-L6-v2")
|
| 387 |
+
tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/all-MiniLM-L6-v2")
|
| 388 |
+
|
| 389 |
+
def encode_documents(documents):
|
| 390 |
+
embeddings = []
|
| 391 |
+
for doc in documents:
|
| 392 |
+
inputs = tokenizer(doc, return_tensors="pt", padding=True, truncation=True)
|
| 393 |
+
with torch.no_grad():
|
| 394 |
+
embeddings.append(embedding_model(**inputs).last_hidden_state.mean(dim=1).numpy())
|
| 395 |
+
return np.vstack(embeddings)
|
| 396 |
+
|
| 397 |
+
document_vectors = encode_documents(documents)
|
| 398 |
+
|
| 399 |
+
# Crearea indexului FAISS
|
| 400 |
+
index = faiss.IndexFlatL2(document_vectors.shape[1]) # Distanta L2
|
| 401 |
+
index.add(document_vectors)
|
| 402 |
+
```
|
| 403 |
+
|
| 404 |
+
#### 4. **Căutarea celor mai relevante documente 🔍**
|
| 405 |
+
|
| 406 |
+
Acum, putem folosi FAISS pentru a căuta documentele cele mai relevante pe baza întrebării utilizatorului:
|
| 407 |
+
|
| 408 |
+
```python
|
| 409 |
+
def retrieve_documents(query, top_k=3):
|
| 410 |
+
query_vector = encode_documents([query]) # Încodifică întrebarea
|
| 411 |
+
distances, indices = index.search(query_vector, top_k) # Căutăm cele mai apropiate documente
|
| 412 |
+
return [documents[i] for i in indices[0]]
|
| 413 |
+
|
| 414 |
+
# Exemplu de interogare
|
| 415 |
+
query = "Cum se folosește RAG în aplicațiile AI?"
|
| 416 |
+
relevant_documents = retrieve_documents(query)
|
| 417 |
+
print(relevant_documents)
|
| 418 |
+
```
|
| 419 |
+
|
| 420 |
+
#### 5. **Generarea răspunsului folosind LLMLit 📝**
|
| 421 |
+
|
| 422 |
+
Acum că avem documentele relevante, le putem utiliza pentru a genera un răspuns contextului întrebării. Vom adăuga aceste documente la promptul nostru pentru LLMLit:
|
| 423 |
+
|
| 424 |
+
```python
|
| 425 |
+
def generate_answer(query, documents):
|
| 426 |
+
context = " ".join(documents) # Adăugăm documentele relevante ca și context
|
| 427 |
+
prompt = f"Întrebare: {query}\nContext: {context}\nRăspuns:"
|
| 428 |
+
|
| 429 |
+
# Tokenizarea promptului
|
| 430 |
+
inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True)
|
| 431 |
+
|
| 432 |
+
# Generarea răspunsului
|
| 433 |
+
outputs = model.generate(inputs['input_ids'], max_length=200, num_beams=5, early_stopping=True)
|
| 434 |
+
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 435 |
+
return answer
|
| 436 |
+
|
| 437 |
+
# Generarea răspunsului final
|
| 438 |
+
answer = generate_answer(query, relevant_documents)
|
| 439 |
+
print(answer)
|
| 440 |
+
```
|
| 441 |
+
|
| 442 |
+
#### 6. **Rezultatul final 🎯**
|
| 443 |
+
|
| 444 |
+
În acest moment, ai un sistem complet RAG care combină **căutarea de documente externe** cu **generarea de text** utilizând LLMLit. Modelul va căuta informațiile relevante în documentele tale și va genera un răspuns informativ și precis.
|
| 445 |
+
|
| 446 |
+
---
|
| 447 |
+
|
| 448 |
+
### **Concluzie 🌟**
|
| 449 |
+
|
| 450 |
+
Implementarea **RAG** folosind **LLMLit** îmbunătățește semnificativ calitatea răspunsurilor oferite de modele de limbaj, deoarece acestea pot accesa o bază de date externă pentru a obține informații mai precise și mai detaliate. Utiliz��nd Hugging Face și librăriile precum FAISS, poți construi un sistem puternic de întrebări și răspunsuri bazat pe RAG.
|
| 451 |
+
|
| 452 |
+
🔗 **Pentru a experimenta cu LLMLit și pentru mai multe informații, vizitează [pagina oficială Hugging Face a modelului LLMLit](https://huggingface.co/LLMLit/LLMLit).**
|
| 453 |
+
|
| 454 |
+
Sper că acest ghid îți va fi de ajutor! 😊
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
|
| 459 |
+
|
| 460 |
Așteptăm cu nerăbdare să lucrăm împreună și să facem pași mari în dezvoltarea AI-ului! 🌍✨
|
| 461 |
|
| 462 |

|