Add OpenRouter integration for engineer prompts#6
Open
tdi649852 wants to merge 3 commits into
Open
Conversation
This implementation allows using OpenRouter API to test multiple LLM
models for engineer prompts instead of local models like vicuna-7b-v1.3.
Changes:
- Add OpenRouterLLM class for API integration (utils/openrouter_llm.py)
- Add OpenRouterBackwardInstructGenerator class (utils/dln.py)
- Add command-line arguments: --use_openrouter, --openrouter_model, --openrouter_api_key
- Update train_opt.py to support OpenRouter mode
- Add comprehensive documentation (OPENROUTER_USAGE.md)
- Update README.md with OpenRouter usage example
- Update .gitignore to exclude openrouter_config.py
Benefits:
- Test multiple LLM models (GPT-4, Claude, Llama, etc.) without local downloads
- Reduce compute requirements for prompt generation
- Flexible model selection via OpenRouter's unified API
Usage:
python train_opt.py --use_openrouter True \
--openrouter_model "meta-llama/llama-3-8b-instruct" \
--data sst2 --ape_mode iid_ibwd
This update allows running DP-OPT entirely via OpenRouter API without
downloading or loading any local LLM models.
Changes:
- Add OpenRouterEvaluator class (utils/evaluate.py) for API-based evaluation
- Update train_opt.py to skip all local model loading when --use_openrouter
- Use OpenRouter for both prompt generation AND evaluation
- Update documentation to reflect no-GPU, no-download operation
Benefits:
- Zero local model downloads - no storage/bandwidth requirements
- No GPU needed - runs entirely on CPU
- Perfect for resource-constrained environments (laptops, low-spec machines)
- Immediate start - no waiting for multi-GB model downloads
Usage:
python train_opt.py --use_openrouter True \
--openrouter_model "meta-llama/llama-3-8b-instruct" \
--data sst2 --device cpu
Note: The --model argument is now optional when using OpenRouter
- Add warning message in OpenRouterEvaluator showing dataset sizes and estimates - Update OPENROUTER_USAGE.md with evaluation limitations and solutions - Recommend --holdout_ratio 0.01 or --skip_eval for faster/cheaper runs - Document that evaluation makes one API call per sample (slow for large sets)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implementation allows using OpenRouter API to test multiple LLM models for engineer prompts instead of local models like vicuna-7b-v1.3.
Changes:
Benefits:
Usage:
python train_opt.py --use_openrouter True \ --openrouter_model "meta-llama/llama-3-8b-instruct" \ --data sst2 --ape_mode iid_ibwd