Comments (8)
Probably needs a supports_prefill = True
option on the class here too:
Lines 243 to 248 in 9ad9ac6
Or should I call that can_prefill
? Need a consistent naming convention here.
The image branch is currently using supports_images
:
Lines 255 to 261 in eaf50d8
from llm.
I like the term "prefill" for this. I think it's a CLI option:
llm -m claude-3-opus 'JSON list of US state names' --prefill '["'
And a Python argument:
model = llm.get_model("claude-3-opus")
response = model.prompt("JSON list of US state names", prefill='["')
from llm.
I'm tempted to switch can_stream
to supports_streaming
for consistency with new options. can_images
doesn't sound as good as supports_images
.
I also want a supports_system
option, since some models don't support system prompts.
from llm.
A couple of things to consider:
- Some APIs might include the prefill in the response, whereas some might not (currently, Claude does not)
- It's possible to mock prefill through prompting, eg OpenAI:
In the latter case, you don't actually know whether the model will include the prefill in the response or not (OpenAI picks one of the other somewhat randomly).
Therefore, perhaps the design of this lib should be that the assistant response always includes the prefill -- and if it's not included in the API response, then its added. And for APIs that don't support prefill (which I guess is anything that doesn't have a completion-based API -- for now is that just OpenAI?) we modify the prompt to mock it.
Does that seem reasonable?
from llm.
Another thought @simonw -- I think there's 4 possibilities for API support:
- Supported by the API, and it eats the prefill so you have to add it back
- Supported by the API, and it includes the prefill in the response
- Not supported by API, but reliably adds the prefill when asked (but may or may not include it in the response)
- Not supported by API, and we haven't found any prompt that results in it reliably adding a prefill
So instead of a supports_prefill
bool, how about an enum with these 4 options? For 1 it adds back the prefill, for 2 it doesn't, for 3 it checks whether it's there and adds it if not, and for 4 it raises an exception if a prefill is requested.
from llm.
In an interesting twist... some of the OpenAI models apparently support this too! https://twitter.com/HamelHusain/status/1782149471624888512
I've found that many OpenAI users do not know about pre-fill with the Chat API
But... it looks like they are a little bit inconsistent about whether they continue the prompt without the prefill or if they answer with the prefill included:
https://twitter.com/HamelHusain/status/1782154898102211053
I found inconsistent behavior with the newest gpt-4-turbo that doesn't conform though (this is consistent across many runs)
from llm.
Another thought @simonw -- I think there's 4 possibilities for API support:
Supported by the API, and it eats the prefill so you have to add it back
Supported by the API, and it includes the prefill in the response
Not supported by API, but reliably adds the prefill when asked (but may or may not include it in the response)
Not supported by API, and we haven't found any prompt that results in it reliably adding a prefill
So instead of a
supports_prefill
bool, how about an enum with these 4 options? For 1 it adds back the prefill, for 2 it doesn't, for 3 it checks whether it's there and adds it if not, and for 4 it raises an exception if a prefill is requested.
The supports_prefill
boolean will actually just let the CLI tool know if it should throw an error if the user passes --prefill "something"
- I'll leave it to custom Python code in each model implementation to handle whether or not that prefill needs to be added to the response. I expect this will be a bit fiddly for the GPT ones - might even need to say "if the response starts with an exact match for the prefill then don't prepend the prefill again".
from llm.
I expect this will be a bit fiddly for the GPT ones - might even need to say "if the response starts with an exact match for the prefill then don't prepend the prefill again".
This is what we decided to do for OpenAI. I think it is a nice approach actually.
from llm.
Related Issues (20)
- llm-llamafile is missing from plugin directory
- How to cut off the LLM in chat mode
- IndexError on Windows for llm chat HOT 1
- llm-groq does not support llama 3 HOT 2
- some plugins fail to install with "Connection refused" error HOT 1
- UI around chat history HOT 1
- [plugin] add IBM watsonx
- A rapidly convert Files to Prompts Using Rust
- Enhancement idea: implement a self help
- Asynchronous API support HOT 1
- Add API documentation on how to import and use this tool as a Python library HOT 1
- Support for GPT-4o HOT 3
- Fix for latest mypy
- Rename the gpt-4-turbo aliases HOT 1
- All I ever get is "insufficient_quota" HOT 5
- llm 0.14: Can't run <<llm chat>> on Windows 11 HOT 1
- llm keys set openai
- Would you be up for a PR that shows help on no options?
- Please add NVIDA cloud API
- Hang on 429 response from OpenAI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llm.