chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
# File To HTML
|
||||
|
||||

|
||||

|
||||
|
||||
The File To HTML pipeline transforms files to HTML. It supports the following text extraction backends.
|
||||
|
||||
## Apache Tika
|
||||
|
||||
[Apache Tika](https://tika.apache.org/) detects and extracts metadata and text from over a thousand different file types. See [this link](https://tika.apache.org/2.9.2/formats.html) for a list of supported document formats.
|
||||
|
||||
Apache Tika requires [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) to be installed. An alternative to that is starting a separate Apache Tika service via [this Docker Image](https://hub.docker.com/r/apache/tika) and setting these [environment variables](https://github.com/chrismattmann/tika-python?tab=readme-ov-file#environment-variables).
|
||||
|
||||
## Docling
|
||||
|
||||
[Docling](https://github.com/DS4SD/docling) parses documents and exports them to the desired format with ease and speed. This is a library that has rapidly gained popularity starting in late 2024. Docling excels in parsing formatting elements from PDFs (tables, sections etc).
|
||||
|
||||
See [this link](https://github.com/DS4SD/docling?tab=readme-ov-file#features) for a list of supported document formats.
|
||||
|
||||
## LiteParse
|
||||
|
||||
[LiteParse](https://github.com/run-llama/liteparse) is a fast, helpful, and open-source document parser. It supports PDF out of the box with additional format support via third-party packages.
|
||||
|
||||
See [this link](https://github.com/run-llama/liteparse#multi-format-input-support) for more.
|
||||
|
||||
## Example
|
||||
|
||||
The following shows a simple example using this pipeline.
|
||||
|
||||
```python
|
||||
from txtai.pipeline import FileToHTML
|
||||
|
||||
# Create and run pipeline
|
||||
html = FileToHTML()
|
||||
html("/path/to/file")
|
||||
```
|
||||
|
||||
## Configuration-driven example
|
||||
|
||||
Pipelines are run with Python or configuration. Pipelines can be instantiated in [configuration](../../../api/configuration/#pipeline) using the lower case name of the pipeline. Configuration-driven pipelines are run with [workflows](../../../workflow/#configuration-driven-example) or the [API](../../../api#local-instance).
|
||||
|
||||
### config.yml
|
||||
```yaml
|
||||
# Create pipeline using lower case class name
|
||||
filetohtml:
|
||||
|
||||
# Run pipeline with workflow
|
||||
workflow:
|
||||
html:
|
||||
tasks:
|
||||
- action: filetohtml
|
||||
```
|
||||
|
||||
### Run with Workflows
|
||||
|
||||
```python
|
||||
from txtai import Application
|
||||
|
||||
# Create and run pipeline with workflow
|
||||
app = Application("config.yml")
|
||||
list(app.workflow("html", ["/path/to/file"]))
|
||||
```
|
||||
|
||||
### Run with API
|
||||
|
||||
```bash
|
||||
CONFIG=config.yml uvicorn "txtai.api:app" &
|
||||
|
||||
curl \
|
||||
-X POST "http://localhost:8000/workflow" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"html", "elements":["/path/to/file"]}'
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
Python documentation for the pipeline.
|
||||
|
||||
### ::: txtai.pipeline.FileToHTML.__init__
|
||||
### ::: txtai.pipeline.FileToHTML.__call__
|
||||
@@ -0,0 +1,68 @@
|
||||
# HTML To Markdown
|
||||
|
||||

|
||||

|
||||
|
||||
The HTML To Markdown pipeline transforms HTML to Markdown.
|
||||
|
||||
Markdown formatting is applied for headings, blockquotes, lists, code, tables and text. Visual formatting is also included (bold, italic etc).
|
||||
|
||||
This pipeline searches for the best node that has relevant text, often found with an `article`, `main` or `body` tag.
|
||||
|
||||
The HTML to Markdown pipeline requires the [BeautifulSoup4](https://pypi.org/project/beautifulsoup4/) library to be installed.
|
||||
|
||||
## Example
|
||||
|
||||
The following shows a simple example using this pipeline.
|
||||
|
||||
```python
|
||||
from txtai.pipeline import HTMLToMarkdown
|
||||
|
||||
# Create and run pipeline
|
||||
md = HTMLToMarkdown()
|
||||
md("<html><body>This is a test</body></html>")
|
||||
```
|
||||
|
||||
## Configuration-driven example
|
||||
|
||||
Pipelines are run with Python or configuration. Pipelines can be instantiated in [configuration](../../../api/configuration/#pipeline) using the lower case name of the pipeline. Configuration-driven pipelines are run with [workflows](../../../workflow/#configuration-driven-example) or the [API](../../../api#local-instance).
|
||||
|
||||
### config.yml
|
||||
```yaml
|
||||
# Create pipeline using lower case class name
|
||||
htmltomarkdown:
|
||||
|
||||
# Run pipeline with workflow
|
||||
workflow:
|
||||
markdown:
|
||||
tasks:
|
||||
- action: htmltomarkdown
|
||||
```
|
||||
|
||||
### Run with Workflows
|
||||
|
||||
```python
|
||||
from txtai import Application
|
||||
|
||||
# Create and run pipeline with workflow
|
||||
app = Application("config.yml")
|
||||
list(app.workflow("markdown", ["<html><body>This is a test</body></html>"]))
|
||||
```
|
||||
|
||||
### Run with API
|
||||
|
||||
```bash
|
||||
CONFIG=config.yml uvicorn "txtai.api:app" &
|
||||
|
||||
curl \
|
||||
-X POST "http://localhost:8000/workflow" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"markdown", "elements":["<html><body>This is a test</body></html>"]}'
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
Python documentation for the pipeline.
|
||||
|
||||
### ::: txtai.pipeline.HTMLToMarkdown.__init__
|
||||
### ::: txtai.pipeline.HTMLToMarkdown.__call__
|
||||
@@ -0,0 +1,69 @@
|
||||
# Segmentation
|
||||
|
||||

|
||||

|
||||
|
||||
The Segmentation pipeline segments text into semantic units.
|
||||
|
||||
## Example
|
||||
|
||||
The following shows a simple example using this pipeline.
|
||||
|
||||
```python
|
||||
from txtai.pipeline import Segmentation
|
||||
|
||||
# Create and run pipeline
|
||||
segment = Segmentation(sentences=True)
|
||||
segment("This is a test. And another test.")
|
||||
|
||||
# Load third-party chunkers
|
||||
segment = Segmentation(chunker="semantic")
|
||||
segment("This is a test. And another test.")
|
||||
```
|
||||
|
||||
The Segmentation pipeline supports segmenting `sentences`, `lines`, `paragraphs` and `sections` using a rules-based approach. Each of these modes can be set when creating the pipeline. Third-party chunkers are also supported via the `chunker` parameter.
|
||||
|
||||
## Configuration-driven example
|
||||
|
||||
Pipelines are run with Python or configuration. Pipelines can be instantiated in [configuration](../../../api/configuration/#pipeline) using the lower case name of the pipeline. Configuration-driven pipelines are run with [workflows](../../../workflow/#configuration-driven-example) or the [API](../../../api#local-instance).
|
||||
|
||||
### config.yml
|
||||
```yaml
|
||||
# Create pipeline using lower case class name
|
||||
segmentation:
|
||||
sentences: true
|
||||
|
||||
# Run pipeline with workflow
|
||||
workflow:
|
||||
segment:
|
||||
tasks:
|
||||
- action: segmentation
|
||||
```
|
||||
|
||||
### Run with Workflows
|
||||
|
||||
```python
|
||||
from txtai import Application
|
||||
|
||||
# Create and run pipeline with workflow
|
||||
app = Application("config.yml")
|
||||
list(app.workflow("segment", ["This is a test. And another test."]))
|
||||
```
|
||||
|
||||
### Run with API
|
||||
|
||||
```bash
|
||||
CONFIG=config.yml uvicorn "txtai.api:app" &
|
||||
|
||||
curl \
|
||||
-X POST "http://localhost:8000/workflow" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"segment", "elements":["This is a test. And another test."]}'
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
Python documentation for the pipeline.
|
||||
|
||||
### ::: txtai.pipeline.Segmentation.__init__
|
||||
### ::: txtai.pipeline.Segmentation.__call__
|
||||
@@ -0,0 +1,71 @@
|
||||
# Tabular
|
||||
|
||||

|
||||

|
||||
|
||||
The Tabular pipeline splits tabular data into rows and columns. The tabular pipeline is most useful in creating (id, text, tag) tuples to load into Embedding indexes.
|
||||
|
||||
## Example
|
||||
|
||||
The following shows a simple example using this pipeline.
|
||||
|
||||
```python
|
||||
from txtai.pipeline import Tabular
|
||||
|
||||
# Create and run pipeline
|
||||
tabular = Tabular("id", ["text"])
|
||||
tabular("path to csv file")
|
||||
```
|
||||
|
||||
See the link below for a more detailed example.
|
||||
|
||||
| Notebook | Description | |
|
||||
|:----------|:-------------|------:|
|
||||
| [Transform tabular data with composable workflows](https://github.com/neuml/txtai/blob/master/examples/22_Transform_tabular_data_with_composable_workflows.ipynb) | Transform, index and search tabular data | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/22_Transform_tabular_data_with_composable_workflows.ipynb) |
|
||||
|
||||
## Configuration-driven example
|
||||
|
||||
Pipelines are run with Python or configuration. Pipelines can be instantiated in [configuration](../../../api/configuration/#pipeline) using the lower case name of the pipeline. Configuration-driven pipelines are run with [workflows](../../../workflow/#configuration-driven-example) or the [API](../../../api#local-instance).
|
||||
|
||||
### config.yml
|
||||
```yaml
|
||||
# Create pipeline using lower case class name
|
||||
tabular:
|
||||
idcolumn: id
|
||||
textcolumns:
|
||||
- text
|
||||
|
||||
# Run pipeline with workflow
|
||||
workflow:
|
||||
tabular:
|
||||
tasks:
|
||||
- action: tabular
|
||||
```
|
||||
|
||||
### Run with Workflows
|
||||
|
||||
```python
|
||||
from txtai import Application
|
||||
|
||||
# Create and run pipeline with workflow
|
||||
app = Application("config.yml")
|
||||
list(app.workflow("tabular", ["path to csv file"]))
|
||||
```
|
||||
|
||||
### Run with API
|
||||
|
||||
```bash
|
||||
CONFIG=config.yml uvicorn "txtai.api:app" &
|
||||
|
||||
curl \
|
||||
-X POST "http://localhost:8000/workflow" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"tabular", "elements":["path to csv file"]}'
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
Python documentation for the pipeline.
|
||||
|
||||
### ::: txtai.pipeline.Tabular.__init__
|
||||
### ::: txtai.pipeline.Tabular.__call__
|
||||
@@ -0,0 +1,82 @@
|
||||
# Textractor
|
||||
|
||||

|
||||

|
||||
|
||||
The Textractor pipeline extracts and splits text from documents. This pipeline extends the [Segmentation](../segmentation) pipeline.
|
||||
|
||||
Each document goes through the following process.
|
||||
|
||||
- Content is retrieved if it's not local
|
||||
- If the document `mime-type` isn't plain text or HTML, it's converted to HTML via the [FiletoHTML](../filetohtml) pipeline
|
||||
- HTML is converted to Markdown via the [HTMLToMarkdown](../htmltomd) pipeline
|
||||
- Content is split/chunked based on the [segmentation parameters](../segmentation/#txtai.pipeline.Segmentation.__init__) and returned
|
||||
|
||||
The [backend](../filetohtml/#txtai.pipeline.FileToHTML.__init__) parameter sets the FileToHTML pipeline backend. If a backend isn't available, this pipeline assumes input is HTML content and only converts it to Markdown.
|
||||
|
||||
See the [FiletoHTML](../filetohtml) and [HTMLToMarkdown](../htmltomd) pipelines to learn more on the dependencies necessary for each of those pipelines.
|
||||
|
||||
Note that the default parameters enable access to all local files and all URLs. The `safeopen` parameter limits this to only files in a specified directory (defaults to temp directory) and public URLs. When running the textractor pipeline through an Application or via the API, `safeopen` defaults to True. It can be disabled if desired via configuration.
|
||||
|
||||
## Example
|
||||
|
||||
The following shows a simple example using this pipeline.
|
||||
|
||||
```python
|
||||
from txtai.pipeline import Textractor
|
||||
|
||||
# Create and run pipeline
|
||||
textract = Textractor()
|
||||
textract("https://github.com/neuml/txtai")
|
||||
```
|
||||
|
||||
See the link below for a more detailed example.
|
||||
|
||||
| Notebook | Description | |
|
||||
|:----------|:-------------|------:|
|
||||
| [Extract text from documents](https://github.com/neuml/txtai/blob/master/examples/10_Extract_text_from_documents.ipynb) | Extract text from PDF, Office, HTML and more | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/10_Extract_text_from_documents.ipynb) |
|
||||
| [Chunking your data for RAG](https://github.com/neuml/txtai/blob/master/examples/73_Chunking_your_data_for_RAG.ipynb) | Extract, chunk and index content for effective retrieval | [](https://colab.research.google.com/github/neuml/txtai/blob/master/examples/73_Chunking_your_data_for_RAG.ipynb) |
|
||||
|
||||
## Configuration-driven example
|
||||
|
||||
Pipelines are run with Python or configuration. Pipelines can be instantiated in [configuration](../../../api/configuration/#pipeline) using the lower case name of the pipeline. Configuration-driven pipelines are run with [workflows](../../../workflow/#configuration-driven-example) or the [API](../../../api#local-instance).
|
||||
|
||||
### config.yml
|
||||
```yaml
|
||||
# Create pipeline using lower case class name
|
||||
textractor:
|
||||
|
||||
# Run pipeline with workflow
|
||||
workflow:
|
||||
textract:
|
||||
tasks:
|
||||
- action: textractor
|
||||
```
|
||||
|
||||
### Run with Workflows
|
||||
|
||||
```python
|
||||
from txtai import Application
|
||||
|
||||
# Create and run pipeline with workflow
|
||||
app = Application("config.yml")
|
||||
list(app.workflow("textract", ["https://github.com/neuml/txtai"]))
|
||||
```
|
||||
|
||||
### Run with API
|
||||
|
||||
```bash
|
||||
CONFIG=config.yml uvicorn "txtai.api:app" &
|
||||
|
||||
curl \
|
||||
-X POST "http://localhost:8000/workflow" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"textract", "elements":["https://github.com/neuml/txtai"]}'
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
Python documentation for the pipeline.
|
||||
|
||||
### ::: txtai.pipeline.Textractor.__init__
|
||||
### ::: txtai.pipeline.Textractor.__call__
|
||||
@@ -0,0 +1,82 @@
|
||||
# Tokenizer
|
||||
|
||||

|
||||

|
||||
|
||||
The Tokenizer pipeline splits text into tokens. This is primarily used for keyword / term indexing.
|
||||
|
||||
_Note: Transformers-based models have their own tokenizers and this pipeline isn't designed for working with Transformers models._
|
||||
|
||||
## Example
|
||||
|
||||
The following shows a simple example using this pipeline.
|
||||
|
||||
```python
|
||||
from txtai.pipeline import Tokenizer
|
||||
|
||||
# Create and run pipeline
|
||||
tokenizer = Tokenizer()
|
||||
tokenizer("text to tokenize")
|
||||
|
||||
# Whitespace tokenization
|
||||
tokenizer = Tokenizer(whitespace=True)
|
||||
tokenizer("text to tokenize")
|
||||
|
||||
# Tokenize using a regular expression
|
||||
tokenizer = Tokenizer(regexp=r"\w{5,}")
|
||||
tokenizer("text to tokenize")
|
||||
|
||||
# Tokenize into trigrams like pg_trgm
|
||||
tokenizer = Tokenizer(ngrams={
|
||||
"ngrams": 3, "lpad": " ", "rpad": " ", "unique": True
|
||||
})
|
||||
tokenize("text to tokenize")
|
||||
|
||||
# Tokenize into edge ngrams
|
||||
tokenizer = Tokenizer(ngrams={"nmin": 2, "nmax": 5, "edge": True})
|
||||
tokenizer("text to tokenize")
|
||||
```
|
||||
|
||||
## Configuration-driven example
|
||||
|
||||
Pipelines are run with Python or configuration. Pipelines can be instantiated in [configuration](../../../api/configuration/#pipeline) using the lower case name of the pipeline. Configuration-driven pipelines are run with [workflows](../../../workflow/#configuration-driven-example) or the [API](../../../api#local-instance).
|
||||
|
||||
### config.yml
|
||||
```yaml
|
||||
# Create pipeline using lower case class name
|
||||
tokenizer:
|
||||
|
||||
# Run pipeline with workflow
|
||||
workflow:
|
||||
tokenizer:
|
||||
tasks:
|
||||
- action: tokenizer
|
||||
```
|
||||
|
||||
### Run with Workflows
|
||||
|
||||
```python
|
||||
from txtai import Application
|
||||
|
||||
# Create and run pipeline with workflow
|
||||
app = Application("config.yml")
|
||||
list(app.workflow("tokenizer", ["text to tokenize"]))
|
||||
```
|
||||
|
||||
### Run with API
|
||||
|
||||
```bash
|
||||
CONFIG=config.yml uvicorn "txtai.api:app" &
|
||||
|
||||
curl \
|
||||
-X POST "http://localhost:8000/workflow" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"tokenizer", "elements":["text"]}'
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
Python documentation for the pipeline.
|
||||
|
||||
### ::: txtai.pipeline.Tokenizer.__init__
|
||||
### ::: txtai.pipeline.Tokenizer.__call__
|
||||
@@ -0,0 +1,62 @@
|
||||
# URL Retrieve
|
||||
|
||||

|
||||

|
||||
|
||||
The URL Retrieve pipeline retrieves content from a HTTP(s) URL.
|
||||
|
||||
## Example
|
||||
|
||||
The following shows a simple example using this pipeline.
|
||||
|
||||
```python
|
||||
from txtai.pipeline import URLRetrieve
|
||||
|
||||
# Create and run pipeline
|
||||
urlretrieve = URLRetrieve()
|
||||
urlretrieve("https://github.com/neuml/txtai")
|
||||
```
|
||||
|
||||
## Configuration-driven example
|
||||
|
||||
Pipelines are run with Python or configuration. Pipelines can be instantiated in [configuration](../../../api/configuration/#pipeline) using the lower case name of the pipeline. Configuration-driven pipelines are run with [workflows](../../../workflow/#configuration-driven-example) or the [API](../../../api#local-instance).
|
||||
|
||||
### config.yml
|
||||
```yaml
|
||||
# Create pipeline using lower case class name
|
||||
urlretrieve:
|
||||
|
||||
# Run pipeline with workflow
|
||||
workflow:
|
||||
retrieve:
|
||||
tasks:
|
||||
- action: urlretrieve
|
||||
```
|
||||
|
||||
### Run with Workflows
|
||||
|
||||
```python
|
||||
from txtai import Application
|
||||
|
||||
# Create and run pipeline with workflow
|
||||
app = Application("config.yml")
|
||||
list(app.workflow("urlretrieve", ["https://github.com/neuml/txtai"]))
|
||||
```
|
||||
|
||||
### Run with API
|
||||
|
||||
```bash
|
||||
CONFIG=config.yml uvicorn "txtai.api:app" &
|
||||
|
||||
curl \
|
||||
-X POST "http://localhost:8000/workflow" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"retrieve", "elements":["http://github.com/neuml/txtai"]}'
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
Python documentation for the pipeline.
|
||||
|
||||
### ::: txtai.pipeline.URLRetrieve.__init__
|
||||
### ::: txtai.pipeline.URLRetrieve.__call__
|
||||
Reference in New Issue
Block a user