Skip to content
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

feat: #formalize, backed by a choice of LLMs #3808

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

semorrison
Copy link
Contributor

This replaces

Typical output:

#formalize "There are infinitely many primes numbers ending with a 7."

produces:

  • GPT4
-- /-- There are infinitely many prime numbers ending with a 7. -/
-- theorem infinitely_many_primes_ending_with_7 : ∀ N : Nat, ∃ p, N < p ∧ p.Prime ∧ p % 10 = 7 :=
--   sorry
  • ggml-gpt4all-j-v1.3-groovy.bin:
-- There are infinitely many prime numbers that end with a 7.
  • 7B/ggml-model-q4_0.bin:
-- ∀ p : nat, 7 < 7p + 1 := sorry
-– \end{code}

There are other sample outputs in test/formalize.lean

If you don't currently have a LLM that the leanprover-community/llm project can recognise, when you run #formalize you get an error message, which currently reads:

Could not find a usable chat bot!

You can try one of the following:
* Obtain an OpenAI API access key at https://platform.openai.com/account/api-keys,
  and store it in the environment variable OPENAI_API_KEY.
  This will enable you to use ChatGPT.
* Download the GPT4All-J model `https://gpt4all.io/models/ggml-gpt4all-j-v1.3-groovy.bin`,
  and put it in either `$HOME/.models/` or `$LLM_MODELS`.
  Also install the gpt4all python bindings via `pip3 install pygpt4all`.
* Clone the `llama.cpp` repository from https://github.com/ggerganov/llama.cpp.
  Set the environment variable `LLAMA_CPP_HOME` to this repository.
  Follow the instructions in the README to produce `7B/ggml-model-q4_0.bin`
  starting from the Meta LLaMa weights.
  You can store this file at one of
  * `$LLAMA_CPP_HOME/models/7B/ggml-model-q4_0.bin`
  * `$HOME/.models/7B/ggml-model-q4_0.bin`
  * `$LLM_MODELS/7B/ggml-model-q4_0.bin`

Currently there are not user-configurable hooks to pick which LLM to use: it checks the conditions described in those bullet points, and takes the first one it finds. (i.e. if you want to use the LLaMa 7B/ggml-model-q4_0.bin, you have to remove your OpenAI API key!). However a tactic in a downstream project (e.g. mathlib) can specify which interface and model it wants to use, or just call findChatBot for the behaviour described in that message.


Open in Gitpod

@semorrison semorrison changed the title feat #formalize, backed by a choice of LLMs feat: #formalize, backed by a choice of LLMs May 5, 2023
@semorrison semorrison added awaiting-review The author would like community review of the PR t-meta Tactics, attributes or user commands labels May 5, 2023
@semorrison semorrison added the merge-conflict The PR has a merge conflict with master, and needs manual merging. label May 17, 2023
@semorrison semorrison removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. label May 17, 2023
@semorrison semorrison added the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Jun 5, 2023
@semorrison semorrison removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Jun 8, 2023
@semorrison semorrison added the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Jul 10, 2023
@semorrison semorrison removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Jul 10, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Jul 27, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Jul 30, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added merge-conflict The PR has a merge conflict with master, and needs manual merging. and removed merge-conflict The PR has a merge conflict with master, and needs manual merging. labels Sep 9, 2023
@jcommelin
Copy link
Member

Would it make sense to make the #formalize command part of the llm package, so that other projects can use it without depending on mathlib?

@jcommelin jcommelin removed the awaiting-review The author would like community review of the PR label Sep 14, 2023
@jcommelin jcommelin added the awaiting-author A reviewer has asked the author a question or requested changes label Sep 14, 2023
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. label Sep 15, 2023
@bors bors bot changed the base branch from master to ScottCarnahan/BinomialRing2 September 17, 2023 03:23
@semorrison semorrison changed the base branch from ScottCarnahan/BinomialRing2 to master September 17, 2023 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author A reviewer has asked the author a question or requested changes merge-conflict The PR has a merge conflict with master, and needs manual merging. t-meta Tactics, attributes or user commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants