Initial upload of FreeChunk model with custom code
Browse files
README.md
CHANGED
|
@@ -32,28 +32,22 @@ pip install torch transformers sentence-transformers numpy
|
|
| 32 |
### Abstract Usage
|
| 33 |
|
| 34 |
```python
|
| 35 |
-
from
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
# 2. Load FreeChunker Model
|
| 43 |
-
model = FreeChunkerModel.from_pretrained("XiaSheng/FreeChunk-jina", trust_remote_code=True)
|
| 44 |
-
model.eval()
|
| 45 |
-
|
| 46 |
-
# 3. Process Text
|
| 47 |
text = "Your text..."
|
| 48 |
-
|
| 49 |
|
| 50 |
-
#
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
# outputs['shift_matrix'] contains chunking information
|
| 57 |
```
|
| 58 |
|
| 59 |
### Manual Pipeline
|
|
|
|
| 32 |
### Abstract Usage
|
| 33 |
|
| 34 |
```python
|
| 35 |
+
from transformers import AutoModel
|
| 36 |
+
import torch
|
| 37 |
+
|
| 38 |
+
# 1. Load Model (UnifiedEncoder)
|
| 39 |
+
model = AutoModel.from_pretrained("XiaSheng/FreeChunk-jina", trust_remote_code=True)
|
| 40 |
+
|
| 41 |
+
# 2. Build Vector Store from Text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
text = "Your text..."
|
| 43 |
+
model.build_vector_store(text)
|
| 44 |
|
| 45 |
+
# 3. Query with Post-Aggregation (Default)
|
| 46 |
+
query = "Your query..."
|
| 47 |
+
results = model.query(query, top_k=1, aggregation_mode='post')
|
| 48 |
+
|
| 49 |
+
print(f"Query: {query}")
|
| 50 |
+
print(f"Result: {results}")
|
|
|
|
| 51 |
```
|
| 52 |
|
| 53 |
### Manual Pipeline
|