The Complete class of the Together Python Library allows you to easily integrate the Together API's completion functionality into your applications, allowing you to generate text with a single line of code.

See all commands with:

together complete --help

Quickstart

Library

Here's an example code block to get started with the complete library:

import together

together.api_key = "xxxxx"

# generate response
response = together.Complete.create(prompt="List places to visit in San Francisco.")

print(response)

Here's an example code block to enable streaming responses from the API:

import together

together.api_key = "xxxxx"

prompt = "List places to visit in San Francisco."

for token in together.Complete.create_streaming(prompt=prompt):
    print(token, end="", flush=True)
print("\n")

Command-line interface

To create a completion query, simply run:

together complete "List places to visit in San Francisco."

By default, complete will query togethercomputer/RedPajama-INCITE-7B-Chat. You can pick a different model with --model or -m followed by the model string.

For example, to query huggyllama/llama-7b, run:

together complete --model huggyllama/llama-7b "List places to visit in San Francisco."

Reference

Library

together.Complete.create()

  • prompt (string, required) -- A string providing context for the model to complete
  • model (string, optional) -- Model string to query. Default: togethercomputer/RedPajama-INCITE-7B-Chat
  • max_tokens (integer, optional) -- Maximum number of tokens the model should generate. Default: 128
  • stop (List[str], optional) -- List of stop words the model should stop generation at. Default: ["<human>"]
  • temperature(float, optional) -- A decimal number that determines the degree of randomness in the response. Default: 0.7
  • top_p (float, optional) -- Used to dynamically adjust the number of choices for each predicted token based on the cumulative probabilities. A value of 1 will always yield the same output. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value greater than 1 introduces more randomness in the output. Default: 0.7
  • top_k (integer, optional) -- Used to limit the number of choices for the next predicted word or token. It specifies the maximum number of tokens to consider at each step, based on their probability of occurrence. This technique helps to speed up the generation process and can improve the quality of the generated text by focusing on the most likely options. Default: 50
  • repetition_penalty (float, optional) -- A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. Default: 1
  • logprobs (integer, optional) -- An integer that specifies how many top token log probabilities are included in the response for each token generation step. Default: None

together.Complete.create_streaming()

  • prompt (string, required) -- A string providing context for the model to complete
  • model (string, optional) -- Model string to query. Default: togethercomputer/RedPajama-INCITE-7B-Chat
  • max_tokens (integer, optional) -- Maximum number of tokens the model should generate. Default: 128
  • stop (List[str], optional) -- List of stop words the model should stop generation at. Default: ["<human>"]
  • temperature(float, optional) -- A decimal number that determines the degree of randomness in the response. Default: 0.7
  • top_p (float, optional) -- Used to dynamically adjust the number of choices for each predicted token based on the cumulative probabilities. A value of 1 will always yield the same output. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value greater than 1 introduces more randomness in the output. Default: 0.7
  • top_k (integer, optional) -- Used to limit the number of choices for the next predicted word or token. It specifies the maximum number of tokens to consider at each step, based on their probability of occurrence. This technique helps to speed up the generation process and can improve the quality of the generated text by focusing on the most likely options. Default: 50
  • repetition_penalty (float, optional) -- A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. Default: 1

Command-line interface

together complete

  • PROMPT (string, required) -- A string providing context for the model to complete
  • --model,-m (string, optional) -- Model string to query. Default: togethercomputer/RedPajama-INCITE-7B-Chat
  • --max-tokens (integer, optional) -- Maximum number of tokens the model should generate. Default: 128
  • --stop (string, optional) -- List of stop words the model should stop generation at. Accepts multiple values. Default: ["<human>"]
  • --temperature(float, optional) -- A decimal number that determines the degree of randomness in the response. Default: 0.7
  • --top-p (float, optional) -- Used to dynamically adjust the number of choices for each predicted token based on the cumulative probabilities. A value of 1 will always yield the same output. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value greater than 1 introduces more randomness in the output. Default: 0.7
  • --top-k (integer, optional) -- Used to limit the number of choices for the next predicted word or token. It specifies the maximum number of tokens to consider at each step, based on their probability of occurrence. This technique helps to speed up the generation process and can improve the quality of the generated text by focusing on the most likely options. Default: 50
  • --repetition-penalty (float, optional) -- A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition. Default: 1
  • --logprobs (integer, optional) -- An integer that specifies how many top token log probabilities are included in the response for each token generation step. Default: None
  • --no-stream (bool, optional) -- Option to turn off streaming. Defaults to stream outputs.
  • --raw (bool, optional) -- Option to output raw response from server.

FAQ

Why do I see a 429 status code error - "No instance started"?

This error is returned by the server if an Inference VM has not been started for the model being queried. To resolve this error, simply navigate to the Playground and start an instance of a model by hitting the "play" button in the model card.

What models are available to run completions on?

See the Models page for a list of models that can be queried. You can also see these models by navigating to the Playground.