opencompass
opencompass copied to clipboard
Add support for Azure, Palm, Anthropic, Cohere, Hugging Face Llama2 70b Models - using litellm
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
- Adding support for more models
- Simplifying maintaining existing model integrations
Please describe the motivation of this PR and the goal you want to achieve through this PR.
Modification
This PR adds support for models from all the above mentioned providers using https://github.com/BerriAI/litellm/
All LLM API Models are guaranteed to have the same Input/Output interface
Here's a sample of how it's used:
from litellm import completion
## set ENV variables
# ENV variables can be set in .env file, too. Example in .env.example
os.environ["OPENAI_API_KEY"] = "openai key"
os.environ["COHERE_API_KEY"] = "cohere key"
os.environ["HF_API_TOKEN"] = "hf-key"
messages = [{ "content": "Hello, how are you?","role": "user"}]
# openai call
response = completion(model="gpt-3.5-turbo", messages=messages)
# hugging face llama2 call
completion(model="meta-llama/llama-2-7b-hf", messages=messages)
# hugging face llama2 Guanaco call
completion(model="TheBloke/llama-2-70b-Guanaco-QLoRA-fp16", messages=messages)
# cohere call
response = completion("command-nightly", messages)
# anthropic call
response = completion(model="claude-instant-1", messages=messages)
Please briefly describe what modification is made in this PR.
BC-breaking (Optional)
Does the modification introduce changes that break the backward compatibility of the downstream repositories? If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here and update the documentation.
Checklist
Before PR:
- [ ] Pre-commit or other linting tools are used to fix the potential lint issues.
- [ ] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
- [ ] The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
- [ ] The documentation has been modified accordingly, like docstring or example tutorials.
After PR:
- [ ] If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects.
- [ ] CLA has been signed and all committers have signed the CLA in this PR.
@gaotongxiao can you please take a look at this PR when possible ?😊
Happy to add more docs/tests if this initial commit looks good
we're rolling out support for all Hugging Face chat+text models - happy to add examples of any if there are specific ones you'd like to add support for
@ishaan-jaff Hi, thanks for the contribution, any update plan?