Skip to content

Commit e80d9bb

Browse files
Merge pull request #309 from stanford-oval/yijia-patch-azuremodel
Fix `AzureOpenAIModel` to match the latest Azure API.
2 parents 39a21e6 + ea39855 commit e80d9bb

33 files changed

+2641
-1201
lines changed

README.md

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
<p align="center">
88
| <a href="http://storm.genie.stanford.edu"><b>Research preview</b></a> | <a href="https://arxiv.org/abs/2402.14207"><b>STORM Paper</b></a>| <a href="https://www.arxiv.org/abs/2408.15232"><b>Co-STORM Paper</b></a> | <a href="https://storm-project.stanford.edu/"><b>Website</b></a> |
99
</p>
10-
1110
**Latest News** 🔥
1211

12+
- [2025/01] We add [litellm](https://github.com/BerriAI/litellm) integration for language models and embedding models in `knowledge-storm` v1.1.0.
13+
1314
- [2024/09] Co-STORM codebase is now released and integrated into `knowledge-storm` python package v1.0.0. Run `pip install knowledge-storm --upgrade` to check it out.
1415

1516
- [2024/09] We introduce collaborative STORM (Co-STORM) to support human-AI collaborative knowledge curation! [Co-STORM Paper](https://www.arxiv.org/abs/2408.15232) has been accepted to EMNLP 2024 main conference.
@@ -92,10 +93,11 @@ You could also install the source code which allows you to modify the behavior o
9293

9394
Currently, our package support:
9495

95-
- `OpenAIModel`, `AzureOpenAIModel`, `ClaudeModel`, `VLLMClient`, `TGIClient`, `TogetherClient`, `OllamaClient`, `GoogleModel`, `DeepSeekModel`, `GroqModel` as language model components
96-
- `YouRM`, `BingSearch`, `VectorRM`, `SerperRM`, `BraveRM`, `SearXNG`, `DuckDuckGoSearchRM`, `TavilySearchRM`, `GoogleSearch`, and `AzureAISearch` as retrieval module components
96+
- Language model components: All language models supported by litellm as listed [here](https://docs.litellm.ai/docs/providers)
97+
- Embedding model components: All embedding models supported by litellm as listed [here](https://docs.litellm.ai/docs/embedding/supported_embedding)
98+
- retrieval module components: `YouRM`, `BingSearch`, `VectorRM`, `SerperRM`, `BraveRM`, `SearXNG`, `DuckDuckGoSearchRM`, `TavilySearchRM`, `GoogleSearch`, and `AzureAISearch` as
9799

98-
:star2: **PRs for integrating more language models into [knowledge_storm/lm.py](knowledge_storm/lm.py) and search engines/retrievers into [knowledge_storm/rm.py](knowledge_storm/rm.py) are highly appreciated!**
100+
:star2: **PRs for integrating more search engines/retrievers into [knowledge_storm/rm.py](knowledge_storm/rm.py) are highly appreciated!**
99101

100102
Both STORM and Co-STORM are working in the information curation layer, you need to set up the information retrieval module and language model module to create their `Runner` classes respectively.
101103

@@ -106,7 +108,7 @@ The STORM knowledge curation engine is defined as a simple Python `STORMWikiRunn
106108
```python
107109
import os
108110
from knowledge_storm import STORMWikiRunnerArguments, STORMWikiRunner, STORMWikiLMConfigs
109-
from knowledge_storm.lm import OpenAIModel
111+
from knowledge_storm.lm import LitellmModel
110112
from knowledge_storm.rm import YouRM
111113
112114
lm_configs = STORMWikiLMConfigs()
@@ -118,8 +120,8 @@ openai_kwargs = {
118120
# STORM is a LM system so different components can be powered by different models to reach a good balance between cost and quality.
119121
# For a good practice, choose a cheaper/faster model for `conv_simulator_lm` which is used to split queries, synthesize answers in the conversation.
120122
# Choose a more powerful model for `article_gen_lm` to generate verifiable text with citations.
121-
gpt_35 = OpenAIModel(model='gpt-3.5-turbo', max_tokens=500, **openai_kwargs)
122-
gpt_4 = OpenAIModel(model='gpt-4o', max_tokens=3000, **openai_kwargs)
123+
gpt_35 = LitellmModel(model='gpt-3.5-turbo', max_tokens=500, **openai_kwargs)
124+
gpt_4 = LitellmModel(model='gpt-4o', max_tokens=3000, **openai_kwargs)
123125
lm_configs.set_conv_simulator_lm(gpt_35)
124126
lm_configs.set_question_asker_lm(gpt_35)
125127
lm_configs.set_outline_gen_lm(gpt_4)
@@ -155,7 +157,7 @@ The Co-STORM knowledge curation engine is defined as a simple Python `CoStormRun
155157

156158
```python
157159
from knowledge_storm.collaborative_storm.engine import CollaborativeStormLMConfigs, RunnerArgument, CoStormRunner
158-
from knowledge_storm.lm import OpenAIModel
160+
from knowledge_storm.lm import LitellmModel
159161
from knowledge_storm.logging_wrapper import LoggingWrapper
160162
from knowledge_storm.rm import BingSearch
161163
@@ -168,12 +170,12 @@ openai_kwargs = {
168170
"top_p": 0.9,
169171
"api_base": None,
170172
}
171-
question_answering_lm = OpenAIModel(model=gpt_4o_model_name, max_tokens=1000, **openai_kwargs)
172-
discourse_manage_lm = OpenAIModel(model=gpt_4o_model_name, max_tokens=500, **openai_kwargs)
173-
utterance_polishing_lm = OpenAIModel(model=gpt_4o_model_name, max_tokens=2000, **openai_kwargs)
174-
warmstart_outline_gen_lm = OpenAIModel(model=gpt_4o_model_name, max_tokens=500, **openai_kwargs)
175-
question_asking_lm = OpenAIModel(model=gpt_4o_model_name, max_tokens=300, **openai_kwargs)
176-
knowledge_base_lm = OpenAIModel(model=gpt_4o_model_name, max_tokens=1000, **openai_kwargs)
173+
question_answering_lm = LitellmModel(model=gpt_4o_model_name, max_tokens=1000, **openai_kwargs)
174+
discourse_manage_lm = LitellmModel(model=gpt_4o_model_name, max_tokens=500, **openai_kwargs)
175+
utterance_polishing_lm = LitellmModel(model=gpt_4o_model_name, max_tokens=2000, **openai_kwargs)
176+
warmstart_outline_gen_lm = LitellmModel(model=gpt_4o_model_name, max_tokens=500, **openai_kwargs)
177+
question_asking_lm = LitellmModel(model=gpt_4o_model_name, max_tokens=300, **openai_kwargs)
178+
knowledge_base_lm = LitellmModel(model=gpt_4o_model_name, max_tokens=1000, **openai_kwargs)
177179
178180
lm_config.set_question_answering_lm(question_answering_lm)
179181
lm_config.set_discourse_manage_lm(discourse_manage_lm)
@@ -222,6 +224,7 @@ We provide scripts in our [examples folder](examples) as a quick start to run ST
222224
We suggest using `secrets.toml` to set up the API keys. Create a file `secrets.toml` under the root directory and add the following content:
223225
224226
```shell
227+
# ============ language model configurations ============
225228
# Set up OpenAI API key.
226229
OPENAI_API_KEY="your_openai_api_key"
227230
# If you are using the API service provided by OpenAI, include the following line:
@@ -230,15 +233,10 @@ OPENAI_API_TYPE="openai"
230233
OPENAI_API_TYPE="azure"
231234
AZURE_API_BASE="your_azure_api_base_url"
232235
AZURE_API_VERSION="your_azure_api_version"
233-
# Set up You.com search API key.
234-
YDC_API_KEY="your_youcom_api_key"
235-
```
236-
237-
for **Co-STORM**, please also add following
238-
```
239-
# if use openai encoder
240-
ENCODER_API_TYPE="openai"
241-
# or ENCODER_API_TYPE="azure" if use azure openai encoder
236+
# ============ retriever configurations ============
237+
BING_SEARCH_API_KEY="your_bing_search_api_key" # if using bing search
238+
# ============ encoder configurations ============
239+
ENCODER_API_TYPE="openai" # if using openai encoder
242240
```
243241
244242
### STORM examples
@@ -249,7 +247,7 @@ Run the following command.
249247
```bash
250248
python examples/storm_examples/run_storm_wiki_gpt.py \
251249
--output-dir $OUTPUT_DIR \
252-
--retriever you \
250+
--retriever bing \
253251
--do-research \
254252
--do-generate-outline \
255253
--do-generate-article \
@@ -328,20 +326,44 @@ We are very grateful to [Michelle Lam](https://michelle123lam.github.io/) for de
328326
## Citation
329327
Please cite our paper if you use this code or part of it in your work:
330328
```bibtex
331-
@misc{jiang2024unknownunknowns,
332-
title={Into the Unknown Unknowns: Engaged Human Learning through Participation in Language Model Agent Conversations},
333-
author={Yucheng Jiang and Yijia Shao and Dekun Ma and Sina J. Semnani and Monica S. Lam},
334-
year={2024},
335-
eprint={2408.15232},
336-
archivePrefix={arXiv},
337-
primaryClass={cs.CL},
338-
url={https://arxiv.org/abs/2408.15232},
329+
@inproceedings{jiang-etal-2024-unknown,
330+
title = "Into the Unknown Unknowns: Engaged Human Learning through Participation in Language Model Agent Conversations",
331+
author = "Jiang, Yucheng and
332+
Shao, Yijia and
333+
Ma, Dekun and
334+
Semnani, Sina and
335+
Lam, Monica",
336+
editor = "Al-Onaizan, Yaser and
337+
Bansal, Mohit and
338+
Chen, Yun-Nung",
339+
booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
340+
month = nov,
341+
year = "2024",
342+
address = "Miami, Florida, USA",
343+
publisher = "Association for Computational Linguistics",
344+
url = "https://aclanthology.org/2024.emnlp-main.554/",
345+
doi = "10.18653/v1/2024.emnlp-main.554",
346+
pages = "9917--9955",
339347
}
340348
341-
@inproceedings{shao2024assisting,
342-
title={{Assisting in Writing Wikipedia-like Articles From Scratch with Large Language Models}},
343-
author={Yijia Shao and Yucheng Jiang and Theodore A. Kanell and Peter Xu and Omar Khattab and Monica S. Lam},
344-
year={2024},
345-
booktitle={Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers)}
349+
@inproceedings{shao-etal-2024-assisting,
350+
title = "Assisting in Writing {W}ikipedia-like Articles From Scratch with Large Language Models",
351+
author = "Shao, Yijia and
352+
Jiang, Yucheng and
353+
Kanell, Theodore and
354+
Xu, Peter and
355+
Khattab, Omar and
356+
Lam, Monica",
357+
editor = "Duh, Kevin and
358+
Gomez, Helena and
359+
Bethard, Steven",
360+
booktitle = "Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers)",
361+
month = jun,
362+
year = "2024",
363+
address = "Mexico City, Mexico",
364+
publisher = "Association for Computational Linguistics",
365+
url = "https://aclanthology.org/2024.naacl-long.347/",
366+
doi = "10.18653/v1/2024.naacl-long.347",
367+
pages = "6252--6278",
346368
}
347369
```

0 commit comments

Comments
 (0)