daniel-simeone commited on
Commit
eb02516
·
1 Parent(s): 99c1869

swap model

Browse files
Files changed (2) hide show
  1. README.md +44 -10
  2. app.py +8 -6
README.md CHANGED
@@ -148,20 +148,54 @@ The chatbot uses Hugging Face Inference API to access high-quality models. You n
148
  - Add a new secret: Name = `HF_TOKEN`, Value = your token
149
  - The app will automatically use this token
150
 
151
- ### Chatbot Model
152
 
153
- The chatbot uses **Mistral-7B-Instruct-v0.2** via Hugging Face Inference API. This is an instruction-tuned model that provides high-quality, coherent answers.
154
 
155
- To change the model, edit `app.py`:
156
 
157
- ```python
158
- chatbot = RAGChatbot(model_name="mistralai/Mistral-7B-Instruct-v0.2")
159
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
- Other recommended instruction-tuned models:
162
- - `HuggingFaceH4/zephyr-7b-beta` - Excellent for chat
163
- - `meta-llama/Meta-Llama-3-8B-Instruct` - High quality (requires access)
164
- - `microsoft/phi-2` - Smaller, faster option
165
 
166
  ### Embedding Model
167
 
 
148
  - Add a new secret: Name = `HF_TOKEN`, Value = your token
149
  - The app will automatically use this token
150
 
151
+ ### Chatbot Model and Finding Available Models
152
 
153
+ The chatbot uses the Hugging Face Inference API. **Which models you can use depends on which providers you have enabled.**
154
 
155
+ **How to see which models are available to you:**
156
 
157
+ 1. **Browse models that support Inference API**
158
+ - https://huggingface.co/inference/models — lists providers and models
159
+ - https://huggingface.co/models?inference_provider=hf-inference — filter Hub models by “HF Inference API”
160
+
161
+ 2. **Enable providers (required)**
162
+ See **“How to enable a provider and model”** below.
163
+
164
+ 3. **Pick a chat model**
165
+ - From the links above, choose a **text generation / chat** model that’s supported by a provider you enabled. Note its **model id** (e.g. `meta-llama/Llama-3.2-1B-Instruct`).
166
+
167
+ 4. **Use it in the app**
168
+ - In `app.py`, pass that model id when creating the chatbot:
169
+ ```python
170
+ chatbot = RAGChatbot(model_name="meta-llama/Llama-3.2-1B-Instruct") # use an id you enabled
171
+ ```
172
+ - The app also tries fallbacks (Phi-2, Zephyr, Qwen) by default; if none are available, enable a provider that supports at least one of them, or set `model_name` to a model you enabled as above.
173
+
174
+ ### How to enable a provider and model
175
+
176
+ 1. **Log in** to [Hugging Face](https://huggingface.co).
177
+
178
+ 2. **Open Inference Provider settings** (one of these, depending on the current UI):
179
+ - https://huggingface.co/settings/inference-providers
180
+ - https://huggingface.co/settings/inference-api
181
+
182
+ 3. **Enable a provider**
183
+ - On that page you’ll see a list of **providers** (e.g. Hugging Face, Together, Groq, etc.).
184
+ - **Turn on** the provider that serves your model (e.g. **Together** for `ServiceNow-AI/Apriel-1.6-15b-Thinker:together`).
185
+ - You can set the **order** of providers; “auto” uses this order to pick which provider handles the request.
186
+
187
+ 4. **Credits / billing**
188
+ - Free accounts get a small amount of monthly credits; usage is deducted from that.
189
+ - If you use a third-party provider (e.g. Together), you can either use HF-routed billing (credits on your HF account) or add a **custom provider API key** (e.g. Together API key) in the same settings so that provider is billed directly.
190
+
191
+ 5. **Confirm the model**
192
+ - Browse models for that provider:
193
+ [Together models on the Hub](https://huggingface.co/models?inference_provider=together&sort=trending)
194
+ - Open the model page (e.g. `ServiceNow-AI/Apriel-1.6-15b-Thinker`) and check the inference widget; if you see “Together” and can run it, that model is available with your enabled provider.
195
 
196
+ 6. **Use it in this app**
197
+ - The app default is already `ServiceNow-AI/Apriel-1.6-15b-Thinker:together`.
198
+ - Ensure **Together** is enabled in your Inference Provider settings and you have credits (or a Together API key). Then restart the app and send a message.
 
199
 
200
  ### Embedding Model
201
 
app.py CHANGED
@@ -87,11 +87,11 @@ class RAGChatbot:
87
  """Chatbot with RAG capabilities."""
88
 
89
  # Default and fallback models (try in order until one is supported by your Inference API providers)
90
- DEFAULT_CHAT_MODEL = "microsoft/phi-2"
91
  FALLBACK_CHAT_MODELS = [
 
 
92
  "HuggingFaceH4/zephyr-7b-beta",
93
- "Qwen/Qwen2-7B-Instruct",
94
- "google/gemma-2-2b-it",
95
  ]
96
 
97
  def __init__(
@@ -234,9 +234,11 @@ Answer:"""
234
  err_str = str(api_error).lower()
235
  if "model_not_supported" in err_str or "not supported by any provider" in err_str:
236
  return (
237
- "None of the configured chat models are available with your Inference API providers. "
238
- "Enable a provider for at least one supported model (e.g. Phi-2, Zephyr, Qwen) at "
239
- "https://huggingface.co/settings/inference-api."
 
 
240
  )
241
  # Fallback: return formatted chunks with note
242
  response_parts = []
 
87
  """Chatbot with RAG capabilities."""
88
 
89
  # Default and fallback models (try in order until one is supported by your Inference API providers)
90
+ DEFAULT_CHAT_MODEL = "Qwen/Qwen2.5-Coder-7B-Instruct"
91
  FALLBACK_CHAT_MODELS = [
92
+ "ServiceNow-AI/Apriel-1.6-15b-Thinker:together",
93
+ "microsoft/phi-2",
94
  "HuggingFaceH4/zephyr-7b-beta",
 
 
95
  ]
96
 
97
  def __init__(
 
234
  err_str = str(api_error).lower()
235
  if "model_not_supported" in err_str or "not supported by any provider" in err_str:
236
  return (
237
+ "None of the configured chat models are available with your Inference API providers.\n\n"
238
+ "**How to fix:**\n"
239
+ "1. See which models are available: https://huggingface.co/inference/models\n"
240
+ "2. Enable providers (and pick a chat model): https://huggingface.co/settings/inference-api\n"
241
+ "3. In app.py, set RAGChatbot(model_name=\"your-chosen-model-id\") to match a model you enabled."
242
  )
243
  # Fallback: return formatted chunks with note
244
  response_parts = []