Skip to content

Support OpenAI reasoning models #1841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Apr 22, 2025
Merged

Support OpenAI reasoning models #1841

merged 19 commits into from
Apr 22, 2025

Conversation

natoverse
Copy link
Collaborator

@natoverse natoverse commented Mar 25, 2025

This updates GraphRAG config and prompting to support the new o* models and the alternate parameters that they require.

In addition to some basic logical switching to make sure the wrong params aren't sent, the primary work here was to rethink some of the prompting (especially for gleanings) to request response lengths without resorting to hard parameter control via max_tokens, which is not possible when using max_completion_tokens in a reasoning model. The prompting is updated to request specific lengths from the model reasoning process directly.

On the search side, this also resolves an issue where we had individual model params that should be taken from the root model configs, so it removes things like temperature and top_p from the config objects.

@natoverse natoverse requested review from a team as code owners March 25, 2025 01:40
@JoedNgangmeni
Copy link

Shouldn't this generate a new settings.yaml with "max_completion_tokens"?

I cloned the repo and checkout this branch.
Then I did pip install graphrag > graphrag init --root ./myDir

I dont see any differences in the settings.yaml file.

It has had the same 2 errors from when I try to run o3 mini on the main branch:

Error 1:
image

I fixed this by uncommenting the encoding line in the config

Error 2:
image

I thought that's what this branch was trying to fix

@natoverse
Copy link
Collaborator Author

Shouldn't this generate a new settings.yaml with "max_completion_tokens"?

I cloned the repo and checkout this branch. Then I did pip install graphrag > graphrag init --root ./myDir

I dont see any differences in the settings.yaml file.

It has had the same 2 errors from when I try to run o3 mini on the main branch:

Error 1: image

I fixed this by uncommenting the encoding line in the config

Error 2: image

I thought that's what this branch was trying to fix

It's a bit more complicated than just swapping out the params. There is an accompanying docs PR that explains the new model differences: https://github.com./microsoft/graphrag/pull/1842/files

You generally don't wan't to use those params at all with the new prompts, so graphrag init will not add them.

@natoverse natoverse mentioned this pull request Apr 21, 2025
3 tasks
@natoverse natoverse merged commit ad4cdd6 into main Apr 22, 2025
15 checks passed
@natoverse natoverse deleted the reasoning-models branch April 22, 2025 21:15
knguyen1 pushed a commit to knguyen1/graphrag that referenced this pull request Apr 24, 2025
* Update tiktoken

* Add max_completion_tokens to model config

* Update/remove outdated comments

* Remove max_tokens from report generation

* Remove max_tokens from entity summarization

* Remove logit_bias from graph extraction

* Remove logit_bias from claim extraction

* Swap params if reasoning model

* Add reasoning model support to basic search

* Add reasoning model support for local and global search

* Support reasoning models with dynamic community selection

* Support reasoning models in DRIFT search

* Remove unused num_threads entry

* Semver

* Update openai

* Add reasoning_effort param
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants