Spaces:
Sleeping
Sleeping
Upload llm_registry.py
Browse files- agents/llm_registry.py +34 -0
agents/llm_registry.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
llm_registry.py - Central llm registry
|
3 |
+
"""
|
4 |
+
|
5 |
+
from transformers import pipeline
|
6 |
+
|
7 |
+
# Registry of available LLMs
|
8 |
+
# These are just examples of models that run fast enough to work in this proof of concept.
|
9 |
+
# But they don't give us good results.
|
10 |
+
# Ideally we would use 'intruct-finetuned' models.
|
11 |
+
# I have tried some models and these actually worked well (i.e. followed the prompt):
|
12 |
+
# microsoft/Phi-3-mini-4k-instruct, Qwen/Qwen2.5-Coder-32B-Instruct,
|
13 |
+
# Qwen/Qwen2.5-72B-Instruct, mistralai/Mistral-7B-Instruct-v0.3,dolly-v2-3b, dolly-v2-12b
|
14 |
+
|
15 |
+
# Note. Need to read the models documentation on how to prompt them. See example for Microsoft's Phi.
|
16 |
+
|
17 |
+
|
18 |
+
LLM_REGISTRY = {
|
19 |
+
"gpt2": {
|
20 |
+
"display_name": "GPT-2",
|
21 |
+
"description": "A medium-sized transformer-based language model by OpenAI.",
|
22 |
+
"model_loader": lambda: pipeline("text-generation", model="gpt2"),
|
23 |
+
},
|
24 |
+
"flan_t5_small": {
|
25 |
+
"display_name": "FLAN-T5 Small",
|
26 |
+
"description": "A fine-tuned T5 model optimized for instruction-following tasks.",
|
27 |
+
"model_loader": lambda: pipeline("text-generation", model="google/flan-t5-small"),
|
28 |
+
},
|
29 |
+
"distilgpt2": {
|
30 |
+
"display_name": "DistilGPT-2",
|
31 |
+
"description": "A smaller and faster version of GPT-2.",
|
32 |
+
"model_loader": lambda: pipeline("text-generation", model="distilgpt2"),
|
33 |
+
},
|
34 |
+
}
|