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

Support for structured output like OpenAI's response format or tools from Claude #802

Open
avalonliberty opened this issue Jan 27, 2025 · 2 comments
Labels
question Further information is requested

Comments

@avalonliberty
Copy link

起始日期 | Start Date

No response

实现PR | Implementation PR

No response

相关Issues | Reference Issues

No response

摘要 | Summary

In many cases, structured output can be utilized to streamline the original workflow. In my understand, MiniCPM only supports prompt engineering to tune its output; however, this adds up a lot of computational power consumption. In my testing, this requires me to send 4 samples to achieve this. Is it possible to support the predefined output like Pytantics' model so that we can ensure the output schema is predictable.

基本示例 | Basic Example

This is the example from OpenAI's doc.

from pydantic import BaseModel
from openai import OpenAI

client = OpenAI()

class CalendarEvent(BaseModel):
    name: str
    date: str
    participants: list[str]

completion = client.beta.chat.completions.parse(
    model="gpt-4o-2024-08-06",
    messages=[
        {"role": "system", "content": "Extract the event information."},
        {"role": "user", "content": "Alice and Bob are going to a science fair on Friday."},
    ],
    response_format=CalendarEvent,
)

event = completion.choices[0].message.parsed

缺陷 | Drawbacks

I don't think there might be any kind of drawbacks

未解决问题 | Unresolved questions

No response

@avalonliberty avalonliberty added the question Further information is requested label Jan 27, 2025
@YuzaChongyi
Copy link
Collaborator

Perhaps you could attempt to preserve the kv-cache to avoid the re-prefill computation.

@avalonliberty
Copy link
Author

Even if I can cache it, the inference time will still be increased given the necessary example prompt, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants