{"id":16092284,"url":"https://github.com/kyegomez/lets-verify-step-by-step","last_synced_at":"2025-07-28T23:33:31.925Z","repository":{"id":171399029,"uuid":"647869872","full_name":"kyegomez/Lets-Verify-Step-by-Step","owner":"kyegomez","description":"\"Improving Mathematical Reasoning with Process Supervision\" by OPENAI ","archived":false,"fork":false,"pushed_at":"2024-04-29T19:08:34.000Z","size":50,"stargazers_count":33,"open_issues_count":5,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-29T20:27:22.527Z","etag":null,"topics":["artificial-intelligence","finetuning","gpt4","gpt4-api","gpt4vision","llama","machine-learning"],"latest_commit_sha":null,"homepage":"https://discord.gg/GYbXvDGevY","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kyegomez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["kyegomez"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-05-31T17:43:15.000Z","updated_at":"2024-04-29T20:27:29.442Z","dependencies_parsed_at":"2024-04-29T20:27:25.611Z","dependency_job_id":null,"html_url":"https://github.com/kyegomez/Lets-Verify-Step-by-Step","commit_stats":null,"previous_names":["kyegomez/process-supervision","kyegomez/lets-verify-step-by-step"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FLets-Verify-Step-by-Step","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FLets-Verify-Step-by-Step/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FLets-Verify-Step-by-Step/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FLets-Verify-Step-by-Step/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyegomez","download_url":"https://codeload.github.com/kyegomez/Lets-Verify-Step-by-Step/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227963319,"owners_count":17848091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","finetuning","gpt4","gpt4-api","gpt4vision","llama","machine-learning"],"created_at":"2024-10-09T16:06:38.268Z","updated_at":"2024-12-03T17:23:04.260Z","avatar_url":"https://github.com/kyegomez.png","language":"Python","funding_links":["https://github.com/sponsors/kyegomez"],"categories":[],"sub_categories":[],"readme":"# \"Let’s Verify Step by Step\"\nImplementation of \"Improving Mathematical Reasoning with Process Supervision\" by OPENAI \n\n## Install\n`pip3 install --upgrade process-supervision-torch`\n\n\n## Usage:\n\n### GPT4 without tokenizer\n```python\nimport torch \nfrom process_supervision.main import GPT4\n\n# Usage with random inputs\ntext = torch.randint(0, 20000, (1, 1024))\n\n# Initiliaze the model\nmodel = GPT4()\noutput = model(text)\nprint(output)\n```\n\n\n### `PRM`\n```python\nimport torch\nfrom process_supervision.prm import PRM\nfrom swarms.models import OpenAIChat\nfrom process_supervision.generator import MathDataGenerator\nimport os\nfrom dotenv import load_dotenv\n\nload_dotenv()\n\napi_key = os.getenv(\"OPENAI_API_KEY\")\n\n# LLM initialization\nllm = OpenAIChat(openai_api_key=api_key)\n\n# Math data generator initialization\nmath_datagenerator = MathDataGenerator(llm, num_iters=10)\n\n# Device initialization\ndevice = 0 if torch.cuda.is_available() else \"cpu\"\n\n# Model initialization\nprm_model = PRM(\n    model_name=\"lvwerra/gpt2-imdb-pos-v2\",\n    ref_model_name=\"lvwerra/gpt2-imdb\",\n    reward_model_name=\"lvwerra/distilbert-imdb\",\n    device=device,\n)\n\n# Generation arguments\ngen_kwargs = {\n    \"min_length\": -1,\n    \"top_k\": 0.0,\n    \"top_p\": 1.0,\n    \"do_sample\": True,\n    \"pad_token_id\": prm_model.tokenizer.eos_token_id,\n}\nsent_kwargs = {\"top_k\": None, \"function_to_apply\": \"none\", \"batch_size\": 16}\n\n# Sample queries\nqueries = [\"Sample query 1\", \"Sample query 2\"]\nqueries = [math_datagenerator.generate_samples(query) for query in queries]\n\n# Generate responses\nresponses = prm_model.generate_responses(\n    queries, gen_len=10, gen_kwargs=gen_kwargs\n)\n\n# Score responses\nscores = prm_model.score_responses(responses, sent_kwargs)\n\n# Display results\nfor query, response, score in zip(queries, responses, scores):\n    print(f\"Query: {query}\\nResponse: {response}\\nScore: {score}\\n\")\n\n```\n\n\n### GPT4 + PRM\n\n\n# Method\n\n\n# Citation\n```bibtex\n@misc{lightman2023lets,\n   title={Let's Verify Step by Step}, \n   author={Hunter Lightman and Vineet Kosaraju and Yura Burda and Harri Edwards and Bowen Baker and Teddy Lee and Jan Leike and John Schulman and Ilya Sutskever and Karl Cobbe},\n   year={2023},\n   eprint={2305.20050},\n   archivePrefix={arXiv},\n   primaryClass={cs.LG}\n}\n\n```\n\n# Todo\n- [ ] We need help integrating the math sample generator, first create the class and prompts and pass them into gpt4\n- [ ] Then conduct best of N sampling with the reward model and reward each step\n- [ ] Train or finetune now model with dataset\n- [ ] Have a better idea? LMK\n\n\n# License\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyegomez%2Flets-verify-step-by-step","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyegomez%2Flets-verify-step-by-step","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyegomez%2Flets-verify-step-by-step/lists"}