Text segmentation and vectorization

Updated at:

This topic describes how to chunk documents and vectorize the resulting chunks using an API.

Request syntax

POST /v3/openapi/apps/{app_group_identity}/actions/knowledge-split

Note: The app_group_identity parameter specifies the application name.

Request parameters

SplitDoc

Parameter name

Parameter Type

Description

Notes

title

String

Dataset title

Optional

content

String

Processing data content

Required

use_embedding

Boolean

Specifies whether to create embeddings for the chunks.

  • True: Yes

  • false: No.

The default value is false.

model

String

The embedding model to use.

None

Sample request body

{
  "title":"Sample title",
  "content":"Sample text",
  "use_embedding":true
}

Response parameters

Response Name

Type

Description

chunks

List<ChunkContext>

Segmented-text data object

ChunkContext

Response Name

Response type

Description

chunk_id

String

The ID of the chunk.

chunk

String

Segmented text data

embedding

String

The embedding vector for the chunk.

type

String

Text type:

Content types: text, image

img_url

String

Image data requires an image URL.

Sample response body

{
  "request_id":"111111111",
  "status":"OK",
  "errors":[],
  "result":[
  {
    "chunk_id":"1",
    "chunk":"Sample chunk text 1",
    "embedding":"-0.010441,-0.002826,-0.022911,0.000847,0.025610,0.019213,-0.019912,0.008210,0.011974,-0.010120,-0.003866,-0.008091,-0.006889,-0.034774,...-0.012572,0.009668,0.010963,-0.005273,-0.005072,-0.002190,-0.001554,-0.000058",
    "type":"text"
  },
  {
    "chunk_id":"2",
    "chunk":"Sample chunk text 2",
    "embedding":"-0.010441,-0.002826,-0.022911,0.000847,0.025610,0.019213,-0.019912,0.008210,0.011974,-0.010120,-0.003866,-0.008091,-0.006889,-0.034774,...-0.012572,0.009668,0.010963,-0.005273,-0.005072,-0.002190,-0.001554,-0.000058",
    "type":"image",
    "img_url":"http://127.0.0.1"
  },
  {
    "chunk_id":"3",
    "chunk":"Sample chunk text 3",
    "type":"text"
  }
]
}
Note

The resulting vectors have 1,536 dimensions.