Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: nisten/Biggie-SmoLlm-0.15B-Base
|
| 3 |
+
license: mit
|
| 4 |
+
datasets:
|
| 5 |
+
- LDJnr/Capybara
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- llama
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
### Fine-tuned [Biggie-SmoLlm-0.15B-Base](https://huggingface.co/nisten/Biggie-SmoLlm-0.15B-Base) for generating subqueries
|
| 13 |
+
|
| 14 |
+
This dude is trained for boosting the performance of your IR app, or RAG
|
| 15 |
+
My motivation was to tackle a core problem of IR with an extremely lightweight, but capable model.
|
| 16 |
+
|
| 17 |
+
If queries are
|
| 18 |
+
- multi-hop logic, break into simpler subqueries that focuses on a different step
|
| 19 |
+
- vague, ask follow up questions
|
| 20 |
+
- multiple sub questions, generate multiple queries for each of them
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
Heads up: [Ollama](https://ollama.com/andthattoo/subquery-smollm) version works 160 tps on 1 CPU core. No GPU? No worries. This little dude’s got you.
|
| 24 |
+
|
| 25 |
+
Use the model:
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
from transformers import AutoModel, AutoConfig, AutoTokenizer, AutoModelForCausalLM
|
| 29 |
+
|
| 30 |
+
config = AutoConfig.from_pretrained("andthattoo/subquery-SmolLM")
|
| 31 |
+
tokenizer = AutoTokenizer.from_pretrained("andthattoo/subquery-SmolLM")
|
| 32 |
+
model = AutoModelForCausalLM.from_pretrained("andthattoo/subquery-SmolLM", torch_dtype=torch.bfloat16)
|
| 33 |
+
|
| 34 |
+
if tokenizer.pad_token is None:
|
| 35 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 36 |
+
model.config.pad_token_id = model.config.eos_token_id
|
| 37 |
+
|
| 38 |
+
input_data = "Generate subqueries for a given question. <question>What is this?</question>"
|
| 39 |
+
inputs = tokenizer(input_data, return_tensors='pt')
|
| 40 |
+
output = model.generate(**inputs, max_new_tokens=100)
|
| 41 |
+
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
Also created a python package for ease of use
|
| 45 |
+
```python
|
| 46 |
+
pip install subquery
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
from subquery import TransformersSubqueryGenerator
|
| 51 |
+
|
| 52 |
+
# Using the Transformers backend
|
| 53 |
+
generator = TransformersSubqueryGenerator()
|
| 54 |
+
result = generator.generate("What is this?")
|
| 55 |
+
|
| 56 |
+
print("Follow-up questions:", result.follow_up)
|
| 57 |
+
print("Subqueries:", result.subquery)
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
or
|
| 61 |
+
|
| 62 |
+
```python
|
| 63 |
+
from subquery import OllamaSubqueryGenerator
|
| 64 |
+
# Using the Ollama backend
|
| 65 |
+
generator = OllamaSubqueryGenerator()
|
| 66 |
+
result = generator.generate("Are the Indiana Harbor and Ship Canal and the Folsom South Canal in the same state?")
|
| 67 |
+
|
| 68 |
+
print("Follow-up questions:", result.follow_up)
|
| 69 |
+
print("Subqueries:", result.subquery)
|
| 70 |
+
```
|