Skip to content

Function calling #9

Open
Open
@sigren

Description

@sigren

When will R1 support function calling and structured outputs? Thanks

Activity

FORNDODAper

FORNDODAper commented on Jan 21, 2025

@FORNDODAper

x2
('x2' stands for 'yeah, i would like to know that too')

reatang

reatang commented on Jan 21, 2025

@reatang

x2 + 1

flyfish101

flyfish101 commented on Jan 21, 2025

@flyfish101

x2 + 2

liberty-rapid

liberty-rapid commented on Jan 21, 2025

@liberty-rapid

x2 + 3

lzl-mt

lzl-mt commented on Jan 21, 2025

@lzl-mt

x2 + 4

juanjopc

juanjopc commented on Jan 21, 2025

@juanjopc

x2 + 5

engalisabry

engalisabry commented on Jan 21, 2025

@engalisabry

Response to Issue #9: Function Calling and Structured Outputs

Thank you for your question and for the community’s interest in this feature! Below, I’ve addressed the current status and future plans for function calling and structured outputs in DeepSeek R1.


Current Status

  • As of now, DeepSeek R1 does not natively support function calling or structured outputs.
  • The model is primarily optimized for reasoning-heavy tasks (e.g., math, code, and STEM) and follows a conversational format.

Future Plans

  • We recognize the importance of function calling and structured outputs for many use cases, such as API integrations, automation, and data extraction.
  • We are actively exploring ways to add support for these features in future updates. This includes:
    • Extending the model’s capabilities to handle structured data formats (e.g., JSON, XML).
    • Adding support for function calling to enable seamless integration with external tools and APIs.

Timeline

  • While we don’t have a specific release date yet, we aim to roll out these features in the next major update.
  • We will keep the community updated on our progress through GitHub announcements and release notes.

Workarounds for Now

If you need structured outputs or function-like behavior in the meantime, here are some workarounds:

  1. Post-Processing Outputs:

    • Use a script to parse the model’s responses into structured formats (e.g., JSON).
    • Example:
      import json
      
      response = model.generate("Extract the following data as JSON: ...")
      structured_data = json.loads(response)
  2. Prompt Engineering:

    • Design prompts to guide the model to produce outputs in a specific format.
    • Example:
      Extract the following information and format it as JSON:
      - Name: ...
      - Age: ...
      - Location: ...
      
  3. Custom Wrapper:

    • Build a custom wrapper around the model to simulate function calling behavior.
    • Example:
      def call_function(model, function_name, args):
          prompt = f"Call function {function_name} with args {args} and return the result."
          return model.generate(prompt)

Community Feedback

We appreciate the enthusiasm from the community (x2 + 5 and counting!). Your feedback is invaluable in shaping the future of DeepSeek R1. If you have specific use cases or feature requests related to function calling and structured outputs, please share them in this thread.


Next Steps

  • We will prioritize this feature based on community demand and provide updates as development progresses.
  • Stay tuned for announcements and feel free to contribute ideas or suggestions!

Thank you for your patience and support as we work to make DeepSeek R1 even better! Let us know if you have further questions or need additional assistance.

ibndias

ibndias commented on Jan 22, 2025

@ibndias

Use R1 as the master brain for tool decision / plan, and rewrite the output in structure with another model.

jacobpretorius

jacobpretorius commented on Jan 22, 2025

@jacobpretorius

I would really like the model to support structured output, such as JSON. For now, no matter how much I tell it to only output JSON it is not consistent. I don't mind the section I think that is useful and very easy to remove with some string handling, but it needs to adhere to JSON output if asked in its final response.

added a commit that references this issue on Jan 22, 2025
449333d
Chrisbattarbee

Chrisbattarbee commented on Jan 22, 2025

@Chrisbattarbee

Also looking for this

feliks912

feliks912 commented on Jan 23, 2025

@feliks912

Bump, definitely bump

jayeew

jayeew commented on Jan 23, 2025

@jayeew

When will R1 support agent?

letscagefdn

letscagefdn commented on Jan 23, 2025

@letscagefdn

response_format: { type: 'json_object' }

69 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @krasserm@hyacinthus@sammcj@chunlea@paulluap

      Issue actions

        Function calling · Issue #9 · deepseek-ai/DeepSeek-R1