Giter Site home page Giter Site logo

Comments (1)

orangetin avatar orangetin commented on August 29, 2024

This can be achieved by specifying "echo": true! Here's an example:

curl https://api.together.xyz/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $TOGETHER_API_KEY" \
  -d '{
    "model": "mistralai/Mistral-7B-Instruct-v0.1",
    "messages": [{"role": "user", "content": "but why?\n\n\n"}],
    "max_tokens": 2,
    "logprobs": 1,
    "temperature": 1,
    "echo": true
  }'

Response:

{
  "id": "86ef1ec809836444-SJC",
  "object": "chat.completion",
  "created": 1712210868,
  "model": "mistralai/Mistral-7B-Instruct-v0.1",
  "prompt": [
    {
      "text": "<s>[INST] but why?\n\n\n [/INST]",
      "logprobs": {
        "token_ids": [
          1,
          28792,
          16289,
          28793,
          562,
          2079,
          28804,
          13,
          13,
          13,
          733,
          28748,
          16289,
          28793
        ],
        "tokens": [
          "<s>",
          "[",
          "INST",
          "]",
          "but",
          "why",
          "?",
          "\n",
          "\n",
          "\n",
          "[",
          "/",
          "INST",
          "]"
        ],
        "token_logprobs": [
          null,
          -20.015625,
          -11.859375,
          -9.1796875,
          -9.328125,
          -3.8691406,
          -2.8476562,
          -0.65234375,
          -0.6142578,
          -4.0664062,
          -10.7578125,
          -5.6484375,
          -11.4453125,
          -8.9140625
        ]
      }
    }
  ],
  "choices": [
    {
      "finish_reason": "length",
      "logprobs": {
        "token_ids": [
          4003,
          349
        ],
        "tokens": [
          " Here",
          " is"
        ],
        "token_logprobs": [
          -6.78125,
          -1.9003906
        ]
      },
      "index": 0,
      "message": {
        "role": "assistant",
        "content": " Here is"
      }
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 2,
    "total_tokens": 17
  }
}

Notice .prompt.text contains the converted message. Additionally, passing in `"logprobs: 1" w/ echo returns prompt logprobs with the response :)

from openapi.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.