Instructions to use Pudding48/TinyLLamaTest with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use Pudding48/TinyLLamaTest with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Pudding48/TinyLLamaTest", filename="tinyllama-1.1b-chat-v1.0.Q8_0.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 Pudding48/TinyLLamaTest with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Pudding48/TinyLLamaTest:Q8_0 # Run inference directly in the terminal: llama-cli -hf Pudding48/TinyLLamaTest:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Pudding48/TinyLLamaTest:Q8_0 # Run inference directly in the terminal: llama-cli -hf Pudding48/TinyLLamaTest:Q8_0
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 Pudding48/TinyLLamaTest:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf Pudding48/TinyLLamaTest:Q8_0
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 Pudding48/TinyLLamaTest:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf Pudding48/TinyLLamaTest:Q8_0
Use Docker
docker model run hf.co/Pudding48/TinyLLamaTest:Q8_0
- LM Studio
- Jan
- Ollama
How to use Pudding48/TinyLLamaTest with Ollama:
ollama run hf.co/Pudding48/TinyLLamaTest:Q8_0
- Unsloth Studio new
How to use Pudding48/TinyLLamaTest 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 Pudding48/TinyLLamaTest 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 Pudding48/TinyLLamaTest to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Pudding48/TinyLLamaTest to start chatting
- Docker Model Runner
How to use Pudding48/TinyLLamaTest with Docker Model Runner:
docker model run hf.co/Pudding48/TinyLLamaTest:Q8_0
- Lemonade
How to use Pudding48/TinyLLamaTest with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Pudding48/TinyLLamaTest:Q8_0
Run and chat with the model
lemonade run user.TinyLLamaTest-Q8_0
List all available models
lemonade list
Delete qabot.py
Browse files
qabot.py
DELETED
|
@@ -1,60 +0,0 @@
|
|
| 1 |
-
from langchain_community.llms import CTransformers
|
| 2 |
-
from langchain.prompts import PromptTemplate
|
| 3 |
-
from langchain_core.runnables import RunnableSequence
|
| 4 |
-
from langchain.chains import RetrievalQA
|
| 5 |
-
from langchain_community.embeddings import GPT4AllEmbeddings
|
| 6 |
-
from langchain_community.vectorstores import FAISS
|
| 7 |
-
|
| 8 |
-
# Cấu hình
|
| 9 |
-
model_file = "tinyllama-1.1b-chat-v1.0.Q8_0.gguf"
|
| 10 |
-
vector_dp_path = "vectorstores/db_faiss"
|
| 11 |
-
|
| 12 |
-
os.makedirs(vector_dp_path, exist_ok=True)
|
| 13 |
-
|
| 14 |
-
# Load LLM
|
| 15 |
-
def load_llm(model_file):
|
| 16 |
-
llm = CTransformers(
|
| 17 |
-
model=model_file,
|
| 18 |
-
model_type="llama",
|
| 19 |
-
temperature=0.01,
|
| 20 |
-
config={'gpu_layers': 0},
|
| 21 |
-
max_new_tokens=128,
|
| 22 |
-
context_length=512
|
| 23 |
-
)
|
| 24 |
-
return llm
|
| 25 |
-
|
| 26 |
-
# Tạo prompt template
|
| 27 |
-
def creat_prompt(template):
|
| 28 |
-
prompt = PromptTemplate(template=template, input_variables=["context","question"])
|
| 29 |
-
return prompt
|
| 30 |
-
|
| 31 |
-
# Tạo pipeline chain (thay cho LLMChain)
|
| 32 |
-
def create_qa_chain(prompt, llm, db):
|
| 33 |
-
llm_chain = RetrievalQA.from_chain_type(
|
| 34 |
-
llm = llm,
|
| 35 |
-
chain_type = "stuff",
|
| 36 |
-
retriever =db.as_retriever(search_kwargs = {"k":1}),
|
| 37 |
-
return_source_documents = False,
|
| 38 |
-
chain_type_kwargs={'prompt':prompt}
|
| 39 |
-
)
|
| 40 |
-
return llm_chain
|
| 41 |
-
|
| 42 |
-
def read_vector_db():
|
| 43 |
-
embedding_model = GPT4AllEmbeddings(model_file = "tinyllama-1.1b-chat-v1.0.Q8_0.gguf")
|
| 44 |
-
db = FAISS.load_local(vector_dp_path, embedding_model,allow_dangerous_deserialization=True)
|
| 45 |
-
return db
|
| 46 |
-
|
| 47 |
-
db = read_vector_db()
|
| 48 |
-
llm = load_llm(model_file)
|
| 49 |
-
# Mẫu prompt
|
| 50 |
-
template = """<|im_start|>system\nSử dụng thông tin sau đây để trả lời câu hỏi. Nếu bạn không biết câu trả lời, hãy nói không biết, đừng cố tạo ra câu trả lời\n
|
| 51 |
-
{context}<|im_end|>\n<|im_start|>user\n{question}<|im_end|>\n<|im_start|>assistant"""
|
| 52 |
-
|
| 53 |
-
# Khởi tạo các thành phần
|
| 54 |
-
prompt = creat_prompt(template)
|
| 55 |
-
llm_chain =create_qa_chain(prompt, llm, db)
|
| 56 |
-
|
| 57 |
-
# Chạy thử chain
|
| 58 |
-
question = "Khoa công nghệ thông tin thành lập năm nào ?"
|
| 59 |
-
response = llm_chain.invoke({"query": question})
|
| 60 |
-
print(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|