# Introduction

The Forefront platform can be used to start—or transition to—fine-tuning and inferencing open-source models.

We offer a variety of [models](https://platform.openai.com/docs/models) at different sizes and price points, and the ability to [import](https://docs.forefront.ai/features/import-from-huggingface), [fine-tune](https://docs.forefront.ai/features/fine-tuning), and [export](https://docs.forefront.ai/features/export-models) custom models.

### Resources

* Experiment in the [Playground](https://forefront.ai/playground)
* Read the [API reference](https://docs.forefront.ai/api-reference/introduction)
* [Fine-tune](https://docs.forefront.ai/features/fine-tuning) custom models
* [Store your model outputs](https://docs.forefront.ai/features/pipelines) in datasets
* [Export your models](https://docs.forefront.ai/features/export-models) to self-host
* [Import models](https://docs.forefront.ai/features/import-from-huggingface) from HuggingFace

{% hint style="info" %}
Protecting your data and model rights are fundamental to our mission. We do not log API requests or train models on your data. You retain all rights to your fine-tuned models and can export them at anytime.
{% endhint %}

## Key concepts

### Text generation models

Forefront enables you to fine-tune and inference open-source text generation models (often referred to as generative pre-trained transformers or "GPT" models for short).&#x20;

These models have been trained to understand natural language, and will generate text outputs in response to their inputs. The inputs to these models are referred to as "prompts".

Writing a prompt is how you "program" a model, usually by providing instructions or some examples of how to successfully complete a task. Text generation models can be used for a variety of tasks including content or code generation, summarization, conversation, creative writing, and more.

Read more in our [text generation guide](https://docs.forefront.ai/features/text-generation).

### Tokens

Text generation models process text in chunks called tokens. Tokens represent commonly occurring sequences of characters. As a rough rule of thumb, 1 token ≈ 4 characters.

For example, the word "reptile" is split into tokens " re", "pt", and "ile"—while a short and common word like " animal" is represented as a single token. Note that in a sentence, the first token of each word typically starts with a space character.&#x20;

One limitation for text generation models is the prompt tokens and generated output tokens combined must be no more than the model's maximum context length. The maximum context lengths for each text generation model can be found [here](https://docs.forefront.ai/get-started/models).

### Fine-tuning

Fine-tuning enables you to customize a model for specific use cases. It lets you get more out of models by providing:

* Higher quality results than prompting
* Ability to train on more examples than can fit in a prompt
* Token savings due to shorter prompts
* Lower latency requests

Read more in our [fine-tuning guide](https://docs.forefront.ai/features/fine-tuning).

### Datasets

Datasets are JSONL files used during fine-tuning that contain example input-output pairs that  you want your fine-tuned model to learn. The examples in your dataset should mimic how you expect to use the model in production.

Here's an example dataset with the two supported formats of prompt and chat completions:

{% tabs %}
{% tab title="Prompt format" %}

```json
{"prompt": "", "completion": ""}
{"prompt": "", "completion": ""}
{"prompt": "", "completion": ""}
```

{% endtab %}

{% tab title="Chat format" %}

```json
{"messages": [{"role": "system", "content": ""}, {"role": "user", "content": ""}, {"role": "assistant", "content": ""}]
{"messages": [{"role": "system", "content": ""}, {"role": "user", "content": ""}, {"role": "assistant", "content": ""}]
{"messages": [{"role": "system", "content": ""}, {"role": "user", "content": ""}, {"role": "assistant", "content": ""}]
```

{% endtab %}
{% endtabs %}

Read more in our [datasets guide](https://docs.forefront.ai/features/datasets).

### Pipelines

Pipelines are a tool for storing LLM outputs to use for fine-tuning.

A common approach to building applications with text generation models is to start by using the most powerful model for your use case, like OpenAI's GPT-4.

This makes it easy to build an initial proof of concept, but comes with tradeoffs like costly inference, high latency, and no model ownership which makes you subject to usage policies and changes to model performance that may not align with your use case.

Pipelines makes it simple to store your current model usage in ready to fine-tune datasets so you can transition to smaller, open-source models. This enables you to own your models and gives you faster latency, cheaper inference, more consistent performance, and the option to self-host.

Read more in our [pipelines guide](https://docs.forefront.ai/features/pipelines).


# Quickstart

Get your local development environment setup and send your first API request.

The Forefront API provides a simple interface for developers to use open-source models in their applications.

This quickstart tutorial will help get your local development environment setup, fine-tune your first model, and start using it in your application.&#x20;

If you are an experienced developer or want to just dive into using the Forefront API, check out the [API reference](https://docs.forefront.ai/api-reference/introduction).

Through this tutorial, you will learn:

1. How to install the latest SDKs
2. Some of the basic concepts of the Forefront API
3. How to fine-tune your first model
4. How to inference your model

If you run into any challenges or have questions getting started, please [contact our team](mailto:support@forefront.ai).

## 1. Create an account

First, create a [Forefront account](https://forefront.ai/sign-up) or [sign in](https://forefront.ai/sign-in). Next, go to the [API key page](https://forefront.ai/app/api-keys) and click "Generate API key". Make sure to save this somewhere safe and do not share it with anyone.

## 2. Install SDK

Forefront provides a custom Node.js and Python library which makes working with the Forefront API simple and efficient. Install the SDK in your preferred language:

{% tabs %}
{% tab title="Python" %}

```
pip install forefront
```

{% endtab %}

{% tab title="Node.js" %}

```
npm i forefront
```

{% endtab %}
{% endtabs %}

## 3. Fine-tune your first model

For the purpose of this tutorial, we'll file-tune Mistral-7B on 1,000 samples from the Open-Hermes-2.5 dataset.

Start by downloading the dataset:

{% file src="/files/LPDf2WLt3eloCxzEAixI" %}
1,000 samples from the Open-Hermes 2.5 dataset by Nous Research
{% endfile %}

{% hint style="info" %}
Before continuing, you can alternatively fine-tune via the UI in the [Forefront platform](https://forefront.ai/app/fine-tune/create).&#x20;
{% endhint %}

## 4. Inference your fine-tuned model

## Next steps

Now that you have fine-tuned your first model and ran it, it's time to explore what else is possible:

* For more detailed information on our models and the API, see our [GPT guide](https://platform.openai.com/docs/guides/text-generation).
* Visit the [OpenAI Cookbook](https://cookbook.openai.com/) for in-depth example API use-cases, as well as code snippets for common tasks.
* Wondering what OpenAI's models are capable of? Check out our library of [example prompts](https://platform.openai.com/examples).
* Want to try the API without writing any code? Start experimenting in the [Playground](https://platform.openai.com/playground).
* Keep our [usage policies](https://openai.com/policies/usage-policies) in mind as you start building.


# Models

The Forefront platform offers various open-source models at different sizes and price points. You can customize these models to your specific use case with [fine-tuning](https://platform.openai.com/docs/guides/fine-tuning).

<table data-full-width="true"><thead><tr><th width="274">Model</th><th>Creator</th><th>License</th><th width="158">Parameters</th><th>Context length</th></tr></thead><tbody><tr><td>Phi-2</td><td>Microsoft</td><td>MIT</td><td>3 billion</td><td>4096</td></tr><tr><td>Mistral-7B</td><td>Mistral</td><td>Apache 2.0</td><td>7 billion</td><td>4096</td></tr><tr><td>Mixtral-7Bx8 (coming soon)</td><td>Mistral</td><td>Apache 2.0</td><td>46.7 billion</td><td>4096</td></tr></tbody></table>

{% hint style="info" %}
Our team is constantly working to provide the latest open-source models. Don't see a model you want? [Let us know.](mailto:support@forefront.ai)
{% endhint %}


# Tutorials

Coming soon.


# Text generation

## Introduction

A large language model (LLM) is a type of machine learning model that has been trained to understand natural language text inputs. LLMs generate text in response to these inputs.

LLMs have been trained on vast amounts of data and excel at all types of tasks that involve text: creating marketing blogs, translating text, and writing computer code to name a few.

A typical LLM input, also known as a "prompt", could include a task, some background information, and instructions on how the model should respond.&#x20;

For example, you might ask an LLM to write a marketing blog about a new product (the task) based on some product data (the background information) in a way that caters to 20-30 year olds (the instructions.) Sometimes the instructions are referred to as "system instructions."

## Getting started

You can interact with LLMs through the [Playground](https://forefront.ai/app/playground) or API. You can also download models and run them from your own machine or in your cloud.

### Playground

To access the playground, log in to <https://platform.forefront.ai> and click on "Playground" in the sidebar. You can select a model in the top-right corner of the screen, type a message into the main input, and click submit to generate a text response.

In the model drop-down you'll be able to select from three types of models:

**Foundation models** are "base layer" models that are trained on the majority of data on the public internet. They contain an incredible amount of knowledge, but are not trained to perform any specific task.

**Community models** are models made by members of the open source community that have been trained, or fine-tuned, to perform a specific task, such as conversation chat.

**My models** are models that you have fine-tuned on your own datasets.

### Completions API

You can interact with models programmatically through our API. Forefront supports two popular formats for sending text inputs to LLMs, **chat style** and **completion style**. *If you're not sure which format to use, start with chat style as it generally produces good results.*

#### Chat style

Chat style is best for conversational use cases as it allows you to send a string of messages to the LLM, where each message has a role of "user" or "assistant". You can also add system instructions by providing a message with the "system" role.

Note: Not all models know how to use chat style out of the box as this ability is learned through specialized training. We sometimes perform this training on models to make them compatible with chat style inputs. We add the label `chat-ml` to these models when we do so.

Below is an example of sending a chat style input to an LLM through the API. Notice that the text input are passed in the `messages` parameter as a list of messages.

{% tabs %}
{% tab title="cURL" %}

```bash
curl https://api.forefront.ai/v1/chat/completions \
  --header 'content-type: application/json' \
  --header 'authorization: Bearer $FOREFRONT_API_KEY' \
  --data '{
        "model": "mistralai/Mistral-7B-v0.1",
        "messages": [
            {
                "role": "system",
                "content": "Respond to the user with beginner-friendly recipes using seasonal ingredients that are commonly found in most grocery stores."
            },
            {
                "role": "user",
                "content": "What is a good chicken recipe"
            }
        ],
        "max_tokens": 64,
        "temperature": 0.5
}'
```

{% endtab %}

{% tab title="Python" %}

```python
# pip install forefront
from forefront import ForefrontClient

# Utils for easily creating messages with roles
# UserChat("hello world") => { "role": "user", "content": "hello world"}
from forefront.utils import SystemChat, UserChat

ff = ForefrontClient(api_key="YOUR API KEY")

completion = ff.chat.completions.create(
    messages=[
        SystemChat("You are a helpful assistant"),
        UserChat("Write a haiku about the ocean"),
    ],
    model="mistralai/Mistral-7B-v0.1",
    temperature=0.5,
    max_tokens=128,
)

```

{% endtab %}

{% tab title="JS/TS" %}

```typescript
// npm install forefront
import Forefront from 'forefront'

const client = new Forefront("YOUR_API_KEY");

const completion = client.chat.completions.create({
    model: "mistralai/Mistral-7B-v0.1",
    messages: [
      {
        role: "user",
        content: "Write a haiku about the ocean",
      },
    ],
    max_tokens: 128,
  });

```

{% endtab %}
{% endtabs %}

#### Completion style

Completion style is used for models that have not been trained to understand chat style inputs and for use cases that require specialized non-conversational syntax.&#x20;

Below is an example of sending a completion style API request. In this case, the text input is passed in the `prompt` parameter:

{% tabs %}
{% tab title="First Tab" %}
{% code overflow="wrap" %}

```bash
curl https://api.forefront.ai/v1/chat/completions \
  --header 'content-type: application/json' \
  --header 'authorization: Bearer $FOREFRONT_API_KEY' \
  --data '{
        "model": "mistralai/Mistral-7B-v0.1",
        "prompt": "Write a script for the opening scene of a movie where Mickey Mouse goes to the beach",
        "max_tokens": 64,
        "temperature": 0.5
}'
```

{% endcode %}

{% endtab %}

{% tab title="Python" %}

```python
# pip install forefront
from forefront import ForefrontClient

# Utils for easily creating messages with roles
# UserChat("hello world") => { "role": "user", "content": "hello world"}
from forefront.utils import SystemChat, UserChat

ff = ForefrontClient(api_key="YOUR API KEY")

completion = ff.chat.completions.create(
    prompt="Write a script for the opening scene of a movie where Mickey Mouse goes to the beach",
    model="mistralai/Mistral-7B-v0.1",
    temperature=0.5,
    max_tokens=128,
)

```

{% endtab %}

{% tab title="JS/TS" %}

```typescript
// npm install forefront
import Forefront from 'forefront'

const client = new Forefront("YOUR_API_KEY");

const completion = client.chat.completions.create({
    model: "mistralai/Mistral-7B-v0.1",
    prompt: "Write a script for the opening scene of a movie where Mickey Mouse goes to the beach",
    max_tokens: 128,
  });
```

{% endtab %}
{% endtabs %}

## Parameters

In addition to the text input, you'll need to pass a few additional parameters to the API, some of which are optional. More information on these parameters can be found in the API reference, but will be briefly explained below.

### **model**

The name of the model that you want to interact with

### **max\_tokens**

The maximum number of tokens the model should output. Depending on the model and use case, the model can generate. For info on what tokens are can be found below.&#x20;

### **temperature**

This is a number between 0 and 1 that represents the level of randomness, or creativity the model should use when generating text. For use cases that require high accuracy i.e writing code, set temperature between 0 and 0.2. For use cases that benefit from some creativity i.e. writing a marketing blog, set temperature between 0.3 and 1.

### **stop**

This an array of words or characters that are used to tell the model when to stop generating text.

## Tokens

It may seem that LLMs generate text one character at a time, but they actually generate text in chunks. These chunks are commonly referred to as "tokens". Tokens range from a single character, to a few characters, or in some cases a full word.

In the phrase `"I am a friendly AI assistant!"`, the corresponding tokens are: `"I`, `am`, `a`, `friendly`, `AI`, `assistant`, `!"`

### Context length

When a model receives a text input, it converts the text to tokens before generating new text. Every model has a maximum amount of tokens that it can process in a single interaction. The maximum number of tokens a model can process is called the **content length**. For example, the context length for the Mistral model on Forefront is 4,096. That means that the input and output tokens for a single request to this model cannot exceed 4,096 tokens.&#x20;

### Tokens as billable units

Tokens are the billable unit when sending requests or fine-tuning with LLMs. It is common for LLM providers (including Forefront) to bill in units of one thousand tokens. Visit our pricing page to see the current rates.


# Fine-tuning

## Introduction

Fine-tuning is a great way to optimize model cost, quality, and latency. Fine-tuning enables higher quality results than prompting alone, and faster/cheaper requests due to shorter prompts.

Fine-tuning a smaller model on the outputs of a larger model can lead to even more dramatic improvements in costs and speed, while ensuring high quality outputs.

## Getting started

You can fine-tune your first model on Forefront in \~30 seconds. At a high level, the fine-tuning step are:

1. Gather a dataset
2. Fine-tune a model
3. Measure performance
4. Deploy the model
5. Iterate

First, you'll need to gather a dataset and format it correctly for fine-tuning. For more info on how to do this visit the datasets page.

Next, go to the [Create Fine-tune](https://platform.forefront.ai/app/fine-tune/create) page, select a model, upload your dataset, optionally set additional parameters, and click **Fine-tune** to kick off your fine-tuning job.

Forefront provides a way of measuring performance quantitatively and qualitatively through loss charts, validation datasets and evals.

Once training is complete, you can try out the model immediately through the playground or API. You can also download the model weights and self-host it if you like.

If your decide your model has room for improvement, simply collect more data and repeat the fine-tuning process.

## When to use fine-tuning&#x20;

There are a few common scenarios when fine-tuning is especially useful:

### Fine-tuning a smaller model on the outputs of a larger model

This strategy is used to enable self-hosting (since larger models require more expensive hardware) and as a cost/latency optimization.  An example of this is collecting example outputs from Mixtral 8x7B and fine-tuning a Mistral 7B model. This enables faster outputs, lower costs and barrier to self-hosting, and higher quality responses than using Mistral 7B without fine-tuning.

### Fine-tuning an open source model on the outputs of a closed source model

Closed-source models can be expensive, and model providers can update the models on a whim leading to unexpected changes in model outputs. Fine-tuning an open source model on the outputs of a closed-source model can lead to higher quality outputs, with the cost and consistency benefits of owning your model.&#x20;

### Improving performance on complex tasks

In general we recommend starting with the best model for the job. If the best model still isn't good enough, then fine-tuning can be helpful to improve performance, especially on complex tasks.&#x20;

## Fine-tuning parameters

There are a few options you can configure when fine-tuning.

### Models

You must select a base model to fine-tune on. You can fine-tune a foundation model or a model that was already fine-tuned.

In general, we recommend selecting a base model that is the best performing for you task. If you want to train a domain-specific chat model for example, you should choose a model that is already trained to understand chat.

Alternatively, you can fine-tune multiple models and see which one performs best. Forefront makes it easy to measure performance qualitatively and quantitatively through evals, validations, and fast experimentation in the playground.

***

You will notice three categories of models to select from in the fine-tuning model drop-down:

**Foundation models** are generally knowledgable, but not trained to perform any task. Choose a foundation model if you want to start with a "clean slate", your dataset uses a unique syntax, or you want the guarantee of using a "trusted" model (foundation models are created by organizations that emphasize safety and alignment during their training processes).

**Community models** are fine-tuned models created by members of the open-source community. These models can exceed performance of foundation models depending on the use case which makes them a great starting point.

**My models** are models that you have previously fine-tuned.

### Epochs

You can select the number of epochs to fine-tune your model, where an epoch is defined as a complete pass through your training dataset. Setting a higher number of epochs can help the model learn complex tasks, but will increase the duration of training. Training for too many epochs can lead to overfitting however.

We recommend starting with a lower number of epochs and monitor performance to see if you should continue training. If it looks like there is room for improvement you can start a new fine-tuning job with more epochs.

**Tip**: If you wish to save on time/cost with training for more epochs, you can fine-tune your previously fine-tuned model for fewer epochs. For example, say you fine-tuned called "my-fine-tuned-model" for two epochs and decide you should train for two more epochs. Instead of creating a new fine-tuning job for four epochs, you could instead choose "my-fine-tuned mode" as your base model and train for two epochs.

### Training dataset

This is the dataset your model will be trained on. Your dataset must be formatted properly using chat-ml or prompt-completion format. For more information on this, see the datasets page.

### Validation dataset

Validation datasets are used to qualitatively evaluate the performance of your model. Once the model has completed fine-tuning, Forefront will inference your fine-tuned model on the samples in your validation dataset. You can view the results in the fine-tuning UI. For best results, make sure your validation dataset does not overlap with the training dataset. Validations will incur inference costs based on the model type

### Evals

Forefront allows you to optionally run automatic evaluations on your fine-tuned models. Once the model has completed fine-tuning, Forefront will start the evals for your model. You can select more than one eval. The results will be shown in the UI once completed. Evals incur inference costs based on the model type.

## Data collection strategies

To get the best fine-tuning results, you should optimize for high-quality training data. Remember, your dataset examples should be representative of how you plan to use your model in production.&#x20;

A few heuristics for achieving this are:

* Include good examples representative of your real-world use case, manually craft them if needed
* Discard low-quality examples, even if that means having a smaller dataset
* Remove duplicates
* Generate high-quality outputs using better models, and fine-tune with them&#x20;
* Don't be afraid to iterate. Fine-tuning with a small dataset, and using your fine-tuned model to generate new examples for fine-tuning is a perfectly reasonable strategy.

For simpler tasks, the easiest way to collect high-quality data is to pull from real-world examples, or to train your model on the outputs of a better model.

For complex tasks, you might need to manually create your dataset or use clever prompting techniques like chain-of-thought to generate an initial dataset that you can fine-tune and iterate on.


# Datasets

Datasets are files used during fine-tuning that contain example input-output pairs that  you want your fine-tuned model to learn. The examples in your dataset should mimic how you expect to use the model in production.

If you want to train your model to write SQL code in response to natural language inputs, your dataset should include a number of examples with natural language inputs and SQL outputs.

## Formatting datasets

Datasets must be **JSONL** files that contain examples in either **chat-ml** or **prompt-completion** format.

**JSONL** (short for JSON lines) is a file format where each line contains a single JSON item.

**Chat-ml** format is a common schema typically used for conversational use cases. It is an array of messages where each message has a role (can be "user", "assistant", or "system") and a content item.&#x20;

Here's an example of a JSONL file that uses chat-ml format for a silly chatbot that sneezes.

```
{"messages": [{"role": "system", "content": "You are a factual chatbot that sneezes in between responses."}, {"role": "user", "content": "What is the largest ocean?"}, {"role": "assistant", "content": "The Pacific Ocean is the... achoo!... largest ocean, covering more than 30% of the Earth's surface."}]}
{"messages": [{"role": "system", "content": "You are a factual chatbot that sneezes in between responses."}, {"role": "user", "content": "What causes rainbows?"}, {"role": "assistant", "content": "Rainbows are caused by the... achoo!... refraction and dispersion of light in water droplets, leading to a spectrum of light in the sky."}]}
{"messages": [{"role": "system", "content": "You are a factual chatbot that sneezes in between responses."}, {"role": "user", "content": "How many planets are in the Solar System?"}, {"role": "assistant", "content": "There are eight planets in the... achoo!... Solar System since Pluto was reclassified as a dwarf planet."}]}
```

**Prompt-completion** is another common format where each sample contains a prompt and completion item. Here is the previous example written using prompt-completion format:

```
{"prompt": "You are a factual chatbot that sneezes in between responses. A user asks, 'What is the largest ocean?'", "completion": "The Pacific Ocean is the... achoo!... largest ocean, covering more than 30% of the Earth's surface."}
{"prompt": "You are a factual chatbot that sneezes in between responses. A user asks, 'What causes rainbows?'","completion": "Rainbows are caused by the... achoo!... refraction and dispersion of light in water droplets, leading to a spectrum of light in the sky."}
{"prompt": "You are a factual chatbot that sneezes in between responses. A user asks, 'How many planets are in the Solar System?'", "completion": "There are eight planets in the... achoo!... Solar System since Pluto was reclassified as a dwarf planet."}
```

## Managing datasets

You can view all of your datasets from the **Data** page by clicking "Data" in the left-hand side bar. There are a number of features related to datasets

### Uploading a dataset

You can upload a dataset from the Data page by clicking the Upload button, or on the Create Fine-tune page.

### Automatic validation

We automatically validate your dataset to make sure it is in the correct format. A dataset status of "Ready" indicates that your dataset has passed validation and is ready for fine-tuning. "Processing" means that validation is still in progress, and "Failed" means that your dataset was not in the correct format. Validation typically happens in a few seconds.&#x20;

If your dataset status is "Failed" but you are using the correct syntax, check to make sure there are no special characters or encoding issues that could cause a parsing issue.

### Dataset inspection

You can easily view the samples in your dataset through the UI by clicking the Inpsect Dataset button in the top-right corner of the page. You can use the arrows to click through examples or the keyboard shortcuts: `j` for left, `k` for right.&#x20;

### Download a dataset

To download your dataset, click the options drop-down in the top-right corner of the page and click Download button. The download will start automatically in your browser.

### Delete a dataset

To delete a dataset, click the options drop-down in the top-right corner and click delete dataset.

##

## Dataset analytics&#x20;

As part of validation, Forefront calculates token analytics for your dataset samples at the aggregate and sample level. These can be easily viewed by clicking into a dataset.

Aggregate analytics include: total tokens, and token counts by role. If using chat-ml syntax, this is user tokens, assistant tokens, and system tokens. If using prompt-completion syntax, this is prompt tokens and completion tokens.

Sample level analytics provide a birds-eye view of the diversity of samples in your dataset.&#x20;

<figure><img src="https://3548480689-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBq69yhv6y6bDEaRQX9GA%2Fuploads%2F7EgcHGWDIvIUM6bzyEdJ%2Fimage.png?alt=media&amp;token=0e993d3c-bbaa-47b8-b4a2-21494d8806ed" alt=""><figcaption></figcaption></figure>

### **Tokens per sample**&#x20;

This is an area chart showing the distribution of token counts in your dataset. In the example above, we can see that the dataset contains 20 samples where "user" messages contain between 300-400 tokens. We can also see that overall the user messages in the dataset tend to skew shorter, where the assistant messages are much longer and varied in length. The blue line represents the system messages which are all very short, less than 100 tokens.

<figure><img src="https://3548480689-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBq69yhv6y6bDEaRQX9GA%2Fuploads%2FXXJzhvkKUXvD9Nrc1Z3s%2Fimage.png?alt=media&amp;token=0940eeb1-1deb-4478-9893-36393337a98e" alt=""><figcaption></figcaption></figure>

### **Unique tokens per sample**&#x20;

This chart is similar to the previous one, and shows the count of unique tokens in each sample. Low token counts could represent either short examples, repetitive language or both. This is not necessarily good or bad, but depends on the use case.

<figure><img src="https://3548480689-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBq69yhv6y6bDEaRQX9GA%2Fuploads%2Ftu3EGlu3jUAUhuXp4vbd%2Fimage.png?alt=media&amp;token=7d54d9e7-d1af-4d97-822c-9a61725c52bf" alt=""><figcaption></figcaption></figure>

### Token type ratios

Token type ratios (TTR) is a measure of lexical diversity in your examples. It is defined as the unique tokens divided by total tokens in each sample. Again, a low or high TTR is not necessarily good or bad, but will depend on your use case.

### **Note on interpreting charts**

The chart analytics should be used a tool to understanding model performance. Let's consider the scenario where a fine-tuned model was trained on the dataset above.&#x20;

Most samples in this dataset contain user messages between 0-500 tokens. We might expect the model to perform well on a request with similar user token counts because it has "seen" this data during training.

Similarly, we might expect the model to perform poorly on requests where user token counts are very high because the model has not seen data like this during training. If this is the case, a simple solution to improve performance would be perform additional fine-tuning using examples with high user token counts.

In general, you can expect a model to perform well on examples it has seen before, and poorly on examples it has not seen. The charts are useful for helping to identify what your overall data looks like.


# Pipelines

Store LLM outputs into ready to fine-tune datasets.

Pipelines are a tool for storing LLM outputs for fine-tuning.

Fine-tuning a smaller model on the outputs of a larger model is a common strategy to optimize cost and performance while ensuring consistent and quality responses.

Using smaller, open-source models can also enable you to self-host due to less-restrictive hardware requirements, giving you ownership of your models and keeping data within your network.

## What is a pipeline?

A pipeline is a collection of LLM outputs that you can easily create, filter, and fine-tune on later.

There are a few steps in the pipeline lifecycle:

1. Create the pipeline
2. Add LLM outputs to the pipeline
3. Filter the pipeline to create a dataset&#x20;
4. Fine-tune a model on the dataset
5. Collect more LLM outputs, add to the pipeline, and repeat

Samples added to a pipeline can be tagged with a user\_id, group\_id, or custom metadata. You can filter pipelines to view segments of your data and create training datasets from those segments.&#x20;

## Getting started

Currently pipelines are only supported through the Forefront Python and Typescript SDK. Below is a walkthrough of how to get started:

### Install the package

The Typescript SDK can be used in Node.js and serverless environments (including Cloudflare workers).

{% tabs %}
{% tab title="Python" %}

```
pip install forefront
```

{% endtab %}

{% tab title="Node.js" %}

```
npm i forefront
```

{% endtab %}
{% endtabs %}

### Initialize the Forefront client

{% tabs %}
{% tab title="Python" %}

```python
from forefront import ForefrontClient

client = ForefrontClient(api_key="<YOUR_API_KEY>")
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
import Forefront from "forefront"

const client = new Forefront("<YOUR API KEY>");
```

{% endtab %}
{% endtabs %}

### Create a pipeline

{% tabs %}
{% tab title="Python" %}

```python
pipeline = ff.pipelines.create("my-first-pipeline")
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
const pipeline = await client.pipelines.create("my-first-pipeline");
```

{% endtab %}
{% endtabs %}

### Get pipelines

{% tabs %}
{% tab title="Python" %}

```python
pipelines = ff.pipelines.list()

print(pipelines[0].id)
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
const pipelines = await client.pipelines.list();

console.log(pipelines[0].id)
```

{% endtab %}
{% endtabs %}

### Get pipeline by ID

{% tabs %}
{% tab title="Python" %}

```python
pipe = ff.pipelines.get_by_id("pipe_123")
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
const pipe = await client.pipelines.getById("pipe_123");
```

{% endtab %}
{% endtabs %}

### Add data to a pipeline

{% tabs %}
{% tab title="Python" %}

````python
# Assume the messages are the output of an LLM
messages = [
    {
        "role": "user", 
        "content": "Write a hello world in rust."
    },
    {
        "role": "assistant",
        "content": '```rust\nfn main() {\nprintln!("Hello, World!");\n}\n```',
    },
]

# Get the pipeline object if you haven't already
pipe = ff.pipelines.get_by_id("pipe_123")

# Add the data to your pipeline
# Optionally add a user_id, group_id, or key-value metadata to filter by later
pipe.add(
    messages=messages,
    user_id='user_123',
    group_id='group_a',
    metadata={
      "lang": "rust"
      }
)
````

{% endtab %}

{% tab title="Node.js" %}

````typescript
// Assume the messages are the output of an LLM
const messages = [
    {
        role: "user", 
        content: "Write a hello world for me in rust"
    },
    {
        role: "assistant",
        content: '```rust\nfn main() {\nprintln!("Hello, World!");\n}\n```',
    },
]

// Get the pipeline object if you haven't already
const pipe = await client.pipelines.getById("pipe_123");

// Add the data to your pipeline
// Optionally add a user_id, group_id, or key-value metadata to filter by later
await pipeline.add({
  messages: messages,
  userId: "user_123",
  groupId: "group_A",
  metadata: {
    lang: "rust",
  },
});
````

{% endtab %}
{% endtabs %}

### Filter pipeline data

{% tabs %}
{% tab title="Python" %}

```python
# Get a pipeline of samples created by "user1"
user_1_examples = pipe.filter_by_user_id("user1")

# Get a pipeline of samples created by "group1"
group_1_examples = pipe.filter_by_group_id("group1"

# Get a pipeline of samples tagged with specific metadata 
rust_examples = pipe.filter_by_metadata({"lang": "rust"})
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
// Get a pipeline of samples created by "user1"
let userSamples = pipe.filterByUserId("user1")

// Get a pipeline of samples created by "group1"
let groupSamples = pipe.filterByGroupId("group1")

// Get a pipeline of samples tagged with specific metadata 
let rustSamples = pipe.filterByMetadata({lang: "rust"})
```

{% endtab %}
{% endtabs %}

### Inspect pipeline data

{% tabs %}
{% tab title="Python" %}

<pre class="language-python"><code class="lang-python">'''
<strong>Returns an array of dataset samples that 
</strong>meets the filter criteria from the previous step
'''
data = await rust_examples.get_samples()
</code></pre>

{% endtab %}

{% tab title="Node.js" %}

```typescript
/*
Returns an array of dataset samples that 
meets the filter criteria from the previous step
*/
let rustSampleData = rustSamples.getSamples()
```

{% endtab %}
{% endtabs %}

### Create dataset from pipeline

To fine-tune a model from a pipeline, you will first need to convert it to a dataset.

{% tabs %}
{% tab title="Python" %}

```python
'''
Create a dataset called "my-rust-dataset using
the filtered pipeline object from the previous step
'''
rust_dataset = rust_examples.create_dataset_from_pipeline("my-rust-dataset")
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
/* 
Create a dataset called "my-rust-dataset using
the filltered pipeline object from the previous step
*/
const myRustdataset = await rustSamples.createDatasetFromPipline("my-rust-dataset");
```

{% endtab %}
{% endtabs %}

### Create a fine-tuned model and inference it

For completeness, here is an example of creating a fine-tuning job from a dataset and then inferencing the model once training is completed.

{% tabs %}
{% tab title="Python" %}

```python
# Create fine-tuned model
my_rust_llm = ff.fine_tunes.create(
     name="my-rust-llm", 
     base_model="mistralai/mistral-7b",
     training_dataset=rust_dataset.dataset_string,
     epochs=1,
     public=False
)

# Get the model string > "team-name/my-rust-llm"
model_string = my_rust_llm.model_string

# Inference the model
completion = ff.chat.completions.create(
    messages=[
        {
            "role":"system", 
            "content":"You are a helpful coding assistant"
        },
        {
            "role": "user", 
            "content": "Write the Fibonacci sequence"
        },
    ],
    model=model_string,
)
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
// Create fine-tuned model
const myRustLlm = await client.fineTunes.create({
   name: "my-rust-llm",
   baseModel: "mistralai/mistral-7b",
   trainingDataset: myRustDataset.datasetString,
   epochs: 1,
   isPublic: true,
 });
 
// Get the model string > "team-name/my-rust-llm"
const modelString = myRustLlm.modelString

// Inference the model
const completion = await client.chat.completions.create({
    model: modelString,
    messages: [
        {
             role:"system", 
             content:"You are a helpful coding assistant"
        },
        {
              role: "user",
              content: "Write the Fibonacci sequence"
        },
    ],
});
```

{% endtab %}
{% endtabs %}


# Export models

Once a fine-tuned model has completed training, you'll be able to export the model weights so that you can run the model on your own.

## How to export a model

To export a model:

* Click on the "Fine-tune" button in the sidebar
* Click on the fine-tuned model that you would like to export
* In the top-right, click the menu dropdown and select "Export Model" as shown below. We will send you an email (if one is provided) when the export job is complete.

![](https://3548480689-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBq69yhv6y6bDEaRQX9GA%2Fuploads%2FKXUUwrxHpTmWOakuH39k%2Fimage.png?alt=media\&token=673cd9bf-f72b-4050-93d5-146abd12ca06)&#x20;

If you've already exported a model, you will instead see a "Get download link" button.![](https://3548480689-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBq69yhv6y6bDEaRQX9GA%2Fuploads%2FQmkL4Zgmd6LbCSkj2Ibr%2Fimage.png?alt=media\&token=9d879dbe-7317-49f5-b093-ecb549fa4ed8)

## Run an exported model with vLLM

Here is a [Colab notebook](https://colab.research.google.com/drive/1wRJPje7PkhjXsGHcxCfiWnbfOOGfLId4?usp=sharing) that shows how to download and run an exported model with [vLLM](https://docs.vllm.ai).


# Import from HuggingFace

## Introduction

Huggingface is great for exploring open-source models, but trying out the models can be difficult without owning your own hardware and/or waiting for model weights to download.

<figure><img src="https://3548480689-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBq69yhv6y6bDEaRQX9GA%2Fuploads%2FshZEr8AnZp4PotgoqSQI%2Fimage.png?alt=media&amp;token=343efe93-28b1-4797-a8ce-c901a90457be" alt=""><figcaption></figcaption></figure>

Forefront offers the unique ability to import Huggingface models for inferencing and fine-tuning. If a model you're interested in isn't already on the platform, you can click "Import from Huggingface" on the Models page and paste in the model string. After a few minutes, the model will be available on the platform. Note this currently only works for Mistral models.

## Automatic chat-ml tuning

Not all models are trained to use the familiar chat-ml syntax as this is a learned ability during fine-tuning. This can make usage of imported models difficult unless you have researched the specific syntax to use.

To improve the experience of model experimentation, Forefront automatically fine-tunes each imported model on a small dataset of chat-ml examples. We've found that this dramatically improves the the chat behavior of most models (although not all) while preserving model quality.&#x20;

These models are specially labeled with the **-chat-ml** suffix and will appear under the Forefront team.&#x20;

You can select if you'd like to use the original model or our chat-ml tuned version of the model. In both the Playground and the API, you can choose to use either chat-ml syntax or prompt-completion syntax depending on which version of the model you are using.

As an example, the imported version Mistral-7B-Instruct-v0.2 is named **mistralai/Mistral-7B-Instruct-v0.2**. Our chat-ml tuned version of the model is named **forefront/Mistral-7B-Instruct-v0.2-chat-ml**

## Tips for using imported models

#### Start with Forefront's chat-tuned version of the model

If you don't know the specific syntax an imported model was trained with, then you will likely want to start by using Forefront's chat-ml tuned version of the model in the playground.&#x20;

#### Research the original syntax used to train the model

If you're still not getting great results, you should figure out the syntax the model was trained with. This information is usually on the Huggingface model page or accompanying research paper.

#### Easily switch between chat and prompt-completion syntax in the playground

You can easily use the prompt-completion syntax in the playground by clicking the Chat dropdown in the upper left of the Playground page.

###


# Introduction

You can interact with the Forefront API through HTTP requests from any language or via our official Python or Typescript package.

To install the SDK, run the following command:

{% tabs %}
{% tab title="Python" %}

```
pip install forefront
```

{% endtab %}

{% tab title="Node.js" %}

```
npm i forefront
```

{% endtab %}
{% endtabs %}


# Authentication

The Forefront API uses API keys for authentication. Visit your [API Keys](https://forefront.ai/app/api-keys) page to retrieve the API key you'll use in your requests.

All API requests should include your API key in an `Authorization` HTTP header as follows:

```
Authorization: Bearer FOREFRONT_API_KEY
```

Alternatively, instantiate your API key with the Python or Node.js package:

{% tabs %}
{% tab title="Python" %}

```python
from Forefront import forefront

client = ForefrontClient(api_key='FOREFRONT_API_KEY')
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
import Forefront from "forefront"

const client = new Forefront("<YOUR API KEY>");
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Remember that your API key is a secret!** Do not share it with others or expose it in any client-side code (browsers or apps). Production requests must be routed through your own backend server where your API key can be securely loaded from an environment variable or key management service.
{% endhint %}


# Chat

Given a list of messages, the model will return a response.

## Create chat completion

## Create chat completion

<mark style="color:green;">`POST`</mark> `https://api.forefront.ai/v1/chat/completions`

Creates a model response for the given chat conversation.

#### Request Body

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| model<mark style="color:red;">\*</mark>    | string  |             |
| messages<mark style="color:red;">\*</mark> | array   |             |
| max\_tokens                                | integer |             |
| temeperature                               | number  |             |
| stop                                       | array   |             |

{% tabs %}
{% tab title="200: OK Successfully returned the chat completion." %}

```typescript
{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Of course! I'm here to help."
      }
    }
  ],
  "usage": {
    "input_tokens": 28,
    "output_tokens": 10,
    "total_tokens": 38
  },
  "message": {
    "content": "Of course! I'm here to help."
  }
}
```

{% endtab %}
{% endtabs %}

### Example request

{% tabs %}
{% tab title="Python" %}

```python
from forefront import ForefrontClient

ff = ForefrontClient(api_key="YOUR_API_KEY")

completion = ff.chat.completions.create(
    messages=[
        {"role": "system", "content" "You are a gourmet chef"},
        {"role": "user", "content": "Write a recipe for an italian dinner"},
    ],
    model="MODEL_STRING", # replace with the name of the model 
    temperature=0,
    max_tokens=10,
)
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
import Forefront from "forefront";

const client = new Forefront("YOUR_API_KEY");

const completion = await client.chat.completions.create({
  model: "MODEL_STRING",
  messages: [
    {
      role: "user",
      content: "Write a recipe for an italian dinner",
    },
  ],
  max_tokens: 256,
  stream: false,
});
```

{% endtab %}

{% tab title="cURL" %}

```
curl https://api.forefront.ai/v1/chat/completions \
--header 'content-type: application/json' \
--header 'authorization: Bearer $FOREFRONT_API_KEY' \
--data '{
    "model": "REPLACE_WITH_MODEL_STRING",
    "messages": [
       {
          "role": "user", 
          "content": "Write a recipe for an italian dinner"
       }
    ],
    "temperature": 0.1,
    "max_tokens": 128,
}'
```

{% endtab %}
{% endtabs %}


# Completions

Given a prompt, the model will return a completion.

## Create completion

<mark style="color:green;">`POST`</mark> `https://api.forefront.ai/v1/chat/completions`

Creates a model response for the given chat conversation.

#### Request Body

| Name                                     | Type    | Description |
| ---------------------------------------- | ------- | ----------- |
| model<mark style="color:red;">\*</mark>  | string  |             |
| prompt<mark style="color:red;">\*</mark> | string  |             |
| max\_tokens                              | integer |             |
| temeperature                             | number  |             |
| stop                                     | array   |             |

{% tabs %}
{% tab title="200: OK Successfully returned the completion." %}

```typescript
{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Of course! I'm here to help..."
      }
    }
  ],
  "usage": {
    "input_tokens": 28,
    "output_tokens": 10,
    "total_tokens": 38
  },
  "message": {
    "content": "Of course! I'm here to help."
  }
}
```

{% endtab %}
{% endtabs %}

### Example request

{% tabs %}
{% tab title="Python" %}

```python
from forefront import ForefrontClient

ff = ForefrontClient(api_key="YOUR_API_KEY")

completion = ff.chat.completions.create(
    prompt="Write a recipe for an italian dinner",
    model="MODEL_STRING", # replace with model string
    temperature=0,
    max_tokens=10,
)
```

{% endtab %}

{% tab title="Node.js" %}

```typescript
import Forefront from "forefront";

const client = new Forefront("YOUR_API_KEY");

const completion: any = await client.chat.completions.create({
  model: "MODEL_STRING",
  prompt: "Write a recipe for an italian dinner",
  max_tokens: 256,
  stream: false,
});
```

{% endtab %}

{% tab title="cURL" %}

```
curl https://api.forefront.ai/v1/chat/completions \
--header 'content-type: application/json' \
--header 'authorization: Bearer $FOREFRONT_API_KEY' \
--data '{
    "model": "REPLACE_WITH_MODEL_STRING",
    "prompt": "What is the meaning of 42?",
    "temperature": 0.1,
    "max_tokens": 128,
}'
```

{% endtab %}
{% endtabs %}


# Fine-tuning

Fine-tune models on your data.

## Create fine-tuned model

## Create fine-tuned model

<mark style="color:green;">`POST`</mark> `https://forefront.ai/v1/fine-tunes/create`

Creates a fine-tuning job which begins the process of training a new model using the given training dataset.

#### Request Body

| Name                                              | Type    | Description                                                                                                  |
| ------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| name<mark style="color:red;">\*</mark>            | String  | The name of your fine-tuned model.                                                                           |
| baseModel<mark style="color:red;">\*</mark>       | String  | The model string of the model to fine-tune.                                                                  |
| trainingDataset<mark style="color:red;">\*</mark> | String  | The dataset string of the training data.                                                                     |
| validationDataset                                 | String  | The dataset string of the validation data.                                                                   |
| epochs                                            | Integer | The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. |

{% tabs %}
{% tab title="200: OK Successfully started the fine-tuning job." %}

{% endtab %}
{% endtabs %}

### Example request

{% tabs %}
{% tab title="Python" %}

{% endtab %}

{% tab title="Node.js" %}

{% endtab %}

{% tab title="cURL" %}

{% endtab %}
{% endtabs %}


# Pipeline

## Create a pipeline

<mark style="color:green;">`POST`</mark> `https://api.forefront.ai/v1/pipelines/create`

Create a new pipeline

#### Request Body

| Name | Type   | Description           |
| ---- | ------ | --------------------- |
| name | String | name of your pipeline |

{% tabs %}
{% tab title="200: OK Returns the pipeline object" %}

```
  {
    "id": "pipe_XXXX",
    "teamId": "your_team_id",
    "name": "test-pipeline",
    "createdAt": "2024-02-01T00:41:28.063Z",
    "updatedAt": "2024-02-01T00:41:28.063Z"
  }
```

{% endtab %}
{% endtabs %}

## List pipelines

<mark style="color:blue;">`GET`</mark> `https://api.forefront.ai/v1/pipelines/list`

Returns a list of your pipelines

{% tabs %}
{% tab title="200: OK " %}

```
[
  {
    "id": "pipe_XXXX",
    "teamId": "your_team_id",
    "name": "test-pipeline",
    "createdAt": "2024-02-01T00:41:28.063Z",
    "updatedAt": "2024-02-01T00:41:28.063Z"
  },
  ...
]
```

{% endtab %}
{% endtabs %}

## Get a pipeline by id

<mark style="color:blue;">`GET`</mark> `https://api.forefront.ai/v1/pipelines/:id`

Returns a pipeline object by id. Does not return pipeline data, see below for how to do that.

#### Path Parameters

| Name | Type   | Description        |
| ---- | ------ | ------------------ |
| id   | String | id of the pipeline |

{% tabs %}
{% tab title="200: OK " %}

```
{
  "id": "pipe_XXXX",
  "teamId": "your_team_id",
  "name": "test-pipeline",
  "createdAt": "2024-02-01T00:44:46.070Z",
  "updatedAt": "2024-02-01T00:44:46.070Z"
}
```

{% endtab %}
{% endtabs %}

## Add to a pipeline

<mark style="color:green;">`POST`</mark> `https://api.forefront.ai/v1/pipelines/:id/add`

Add data to a pipeline

#### Path Parameters

| Name | Type   | Description        |
| ---- | ------ | ------------------ |
| id   | String | id of the pipeline |

#### Request Body

| Name                                       | Type   | Description                                                                         |
| ------------------------------------------ | ------ | ----------------------------------------------------------------------------------- |
| messages<mark style="color:red;">\*</mark> | Array  | Array of messages in chat-ml format. See datasets page for details on how to format |
| userId                                     | String | Add a user\_id to the sample                                                        |
| groupId                                    | String | Add a group\_id to the sample                                                       |
| metadata                                   | Object | Add custom key-value string labels to a sample                                      |

{% tabs %}
{% tab title="200: OK " %}

```
{
  "id": <id of the data sample>
}
```

{% endtab %}
{% endtabs %}

## Pipeline selections

Pipeline selections allow you to filter data in a pipeline. Pipelines can be filtered by userId, groupId, metadata, as well as limiting and paginating the number of responses.

You can create datasets from pipeline selections, inspect the individual data samples, and get a count of data that meets pipeline selection criteria.

## Get data sample for a pipeline selection

<mark style="color:green;">`POST`</mark> `https://api.forefront.ai/v1/pipelines/:id/samples`

Returns array of data samples for a pipeline that meets filter criteria, if provided. Otherwise returns all data in pipeline. Each returned item contains a signed url that you can use to retrieve the text contents. The SDKs will automatically download the text contents from these urls.

#### Request Body

| Name     | Type   | Description                                             |
| -------- | ------ | ------------------------------------------------------- |
| limit    | Number | Number of samples to return                             |
| offset   | Number | Return examples after offset value. Used for pagination |
| userId   | String | Filter results by user id                               |
| groupId  | String | Filter results by group id                              |
| metadata | Object | Filter results by data that matches provided metadata   |

{% tabs %}
{% tab title="200: OK " %}

```json
[
  {
    "id": <id of the sample>,
    "length": 1, // number of messages in the sample
    "pipelineId": "pipe_XXXX",
    "teamId": "your_team_id",
    "createdAt": "2024-02-01T00:52:14.555Z",
    "userId": <userId if one provided>, // or null
    "groupId": <groupId if one provided>, // or null
    "metadata": <metadata if provided>, // or null
    "url": <signed_url> 
  },
  ...
]
```

{% endtab %}
{% endtabs %}

## Get count of pipeline selection

<mark style="color:green;">`POST`</mark> `https://api.forefront.ai/v1/pipelines/:id/count`

Returns count of data samples that match filter criteria if provided, otherwise returns count of all data samples in pipeline

#### Request Body

| Name     | Type   | Description                                             |
| -------- | ------ | ------------------------------------------------------- |
| limit    | Number | Number of samples to return                             |
| offset   | Number | Return examples after offset value. Used for pagination |
| userId   | String | Filter results by user id                               |
| groupId  | String | Filter results by group id                              |
| metadata | String | Filter results by data that matches provided metadata   |

{% tabs %}
{% tab title="200: OK " %}

```
{
  "count": 100
}
```

{% endtab %}
{% endtabs %}

## Create a dataset from a pipeline selection&#x20;

<mark style="color:green;">`POST`</mark> `https://api.forefront.ai/v1/pipelines/:id/create-dataset`

Create a dataset from a pipeline that matches filter criteria, if provided. Otherwise creates a dataset with all data in the pipeline

#### Request Body

| Name                                   | Type   | Description     |
| -------------------------------------- | ------ | --------------- |
| name<mark style="color:red;">\*</mark> | String | Name of dataset |

{% tabs %}
{% tab title="200: OK " %}

```
{
  "id": "data_XXXX",
  "name": "<dataset name>",
  "teamId": "your_team_id",
  "datasetString": "<your team prefix>/<dataset name>",
  "size": 1000,
  "status": "PROCESSING",
  "createdAt": "2024-02-01T01:11:27.425Z",
  "deletedAt": null
}
```

{% endtab %}
{% endtabs %}


# Troubleshooting


