Instructions to use sushruthsam/code_chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use sushruthsam/code_chat with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="sushruthsam/code_chat", filename="mistral-7b-instruct-v0.1.Q2_K.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use sushruthsam/code_chat with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf sushruthsam/code_chat:Q2_K # Run inference directly in the terminal: llama-cli -hf sushruthsam/code_chat:Q2_K
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf sushruthsam/code_chat:Q2_K # Run inference directly in the terminal: llama-cli -hf sushruthsam/code_chat:Q2_K
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 sushruthsam/code_chat:Q2_K # Run inference directly in the terminal: ./llama-cli -hf sushruthsam/code_chat:Q2_K
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 sushruthsam/code_chat:Q2_K # Run inference directly in the terminal: ./build/bin/llama-cli -hf sushruthsam/code_chat:Q2_K
Use Docker
docker model run hf.co/sushruthsam/code_chat:Q2_K
- LM Studio
- Jan
- Ollama
How to use sushruthsam/code_chat with Ollama:
ollama run hf.co/sushruthsam/code_chat:Q2_K
- Unsloth Studio new
How to use sushruthsam/code_chat 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 sushruthsam/code_chat 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 sushruthsam/code_chat to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for sushruthsam/code_chat to start chatting
- Docker Model Runner
How to use sushruthsam/code_chat with Docker Model Runner:
docker model run hf.co/sushruthsam/code_chat:Q2_K
- Lemonade
How to use sushruthsam/code_chat with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull sushruthsam/code_chat:Q2_K
Run and chat with the model
lemonade run user.code_chat-Q2_K
List all available models
lemonade list
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from ctransformers import AutoModelForCausalLM
|
| 3 |
+
|
| 4 |
+
# Load the model
|
| 5 |
+
llm = AutoModelForCausalLM.from_pretrained(
|
| 6 |
+
model_path_or_repo_id="mistral-7b-instruct-v0.2.Q2_K.gguf",
|
| 7 |
+
model_type="mistral",
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
st.title("Conversational Chat with Mistral 🦙🗨️")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
# Function to generate response
|
| 14 |
+
def generate_response(user_query):
|
| 15 |
+
prompt = f"""The user query is '{user_query}'"""
|
| 16 |
+
args = {
|
| 17 |
+
"prompt": prompt,
|
| 18 |
+
"stream": True,
|
| 19 |
+
"max_new_tokens": 2048,
|
| 20 |
+
"temperature": 0,
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
response_placeholder = st.empty() # Placeholder for displaying response chunks
|
| 24 |
+
|
| 25 |
+
response_so_far = "" # Initialize empty string to store cumulative response
|
| 26 |
+
|
| 27 |
+
for chunk in llm(**args):
|
| 28 |
+
response_so_far += chunk # Append current chunk to cumulative response
|
| 29 |
+
response_placeholder.write(response_so_far) # Display cumulative response
|
| 30 |
+
|
| 31 |
+
return # No need to return anything
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# User input
|
| 35 |
+
user_query = st.text_input("Enter your query:", "")
|
| 36 |
+
|
| 37 |
+
if user_query:
|
| 38 |
+
# Generate and display response
|
| 39 |
+
generate_response(user_query)
|