You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/content/docs/optimization.mdx
+18-7Lines changed: 18 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,8 +74,19 @@ Optimization can significantly improve accuracy on real-world tasks:
74
74
75
75
## Persisting Results
76
76
77
-
Saving/loading an optimized extractor is not yet implemented.
78
-
For now, re-run `optimize()` when you start up, or persist your training data and configuration.
77
+
Save and load optimized extractors to reuse them without re-running optimization:
78
+
79
+
```python
80
+
# Save after optimization
81
+
extractor.save("./my_extractor")
82
+
83
+
# Load later
84
+
from langstruct import LangStruct
85
+
loaded = LangStruct.load("./my_extractor")
86
+
87
+
# Use immediately - optimization is preserved
88
+
result = loaded.extract("new text")
89
+
```
79
90
80
91
## Advanced (If You Need It)
81
92
@@ -110,25 +121,25 @@ extractor.optimize(
110
121
## Common Questions
111
122
112
123
**Q: Do I always need training data?**
113
-
A: No! Optimization can work without training data, but providing examples improves results significantly.
124
+
A: You need example texts, but not necessarily expected outputs. If you don't provide `expected_results`, LangStruct uses the LLM's confidence ratings to optimize. Providing expected outputs significantly improves accuracy.
114
125
115
126
**Q: How long does optimization take?**
116
127
A: Usually 1-5 minutes for typical datasets (10-100 examples).
117
128
118
129
**Q: Can I optimize an already optimized extractor?**
119
-
A: Yes! You can keep optimizing with new data as you get it.
130
+
A: Yes, you can continue optimizing with new data as you collect it.
120
131
121
132
**Q: Will this make my extractions slower?**
122
-
A: No - optimization happens once during training. Production extraction speed is the same.
133
+
A: No - optimization happens once during training. Production extraction speed is unchanged.
123
134
124
135
**Q: What happens when I switch models?**
125
-
A: Just change the model and re-optimize! Same training data, same accuracy - zero prompt rewriting needed.
136
+
A: Change the model and re-optimize with the same training data. No prompt rewriting needed.
126
137
127
138
## Next Steps
128
139
129
140
<CardGrid>
130
141
<Cardtitle="Try It Now"icon="laptop">
131
-
Create a LangStruct extractor and enable optimization when you need accuracy!
142
+
Create a LangStruct extractor and enable optimization when you need accuracy.
132
143
</Card>
133
144
<Cardtitle="Source Grounding"icon="document">
134
145
[Track where information comes from](/source-grounding/)
0 commit comments