langchain/docs/ecosystem
Matt Robinson 63aa28e2a6
feat: allow the unstructured kwargs to be passed in to Unstructured document loaders (#1667)
### Summary

Allows users to pass in `**unstructured_kwargs` to Unstructured document
loaders. Implemented with the `strategy` kwargs in mind, but will pass
in other kwargs like `include_page_breaks` as well. The two currently
supported strategies are `"hi_res"`, which is more accurate but takes
longer, and `"fast"`, which processes faster but with lower accuracy.
The `"hi_res"` strategy is the default. For PDFs, if `detectron2` is not
available and the user selects `"hi_res"`, the loader will fallback to
using the `"fast"` strategy.


### Testing

#### Make sure the `strategy` kwarg works

Run the following in iPython to verify that the `"fast"` strategy is
indeed faster.

```python
from langchain.document_loaders import UnstructuredFileLoader

loader = UnstructuredFileLoader("layout-parser-paper-fast.pdf", strategy="fast", mode="elements")
%timeit loader.load()

loader = UnstructuredFileLoader("layout-parser-paper-fast.pdf", mode="elements")
%timeit loader.load()
```

On my system I get:

```python
In [3]: from langchain.document_loaders import UnstructuredFileLoader

In [4]: loader = UnstructuredFileLoader("layout-parser-paper-fast.pdf", strategy="fast", mode="elements")

In [5]: %timeit loader.load()
247 ms ± 369 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)

In [6]: loader = UnstructuredFileLoader("layout-parser-paper-fast.pdf", mode="elements")

In [7]: %timeit loader.load()
2.45 s ± 31 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
```

#### Make sure older versions of `unstructured` still work

Run `pip install unstructured==0.5.3` and then verify the following runs
without error:

```python
from langchain.document_loaders import UnstructuredFileLoader

loader = UnstructuredFileLoader("layout-parser-paper-fast.pdf",  mode="elements")
loader.load()
```
2023-03-14 18:15:28 -07:00
..
ai21.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
atlas.md AtlasDB vector store documentation updates. (#1572) 2023-03-09 16:31:14 -08:00
bananadev.md [DOCS] Assorted wording, punctuation, and consistency revisions (#1443) 2023-03-08 20:16:09 -08:00
cerebriumai.md Add GooseAI, CerebriumAI, Petals, ForefrontAI (#981) 2023-02-13 21:20:19 -08:00
chroma.md improve docs for indexes (#1146) 2023-02-19 23:14:50 -08:00
cohere.md improve docs for indexes (#1146) 2023-02-19 23:14:50 -08:00
deepinfra.md Add DeepInfra LLM support (#1232) 2023-02-23 07:37:15 -08:00
deeplake.md Harrison/deeplake (#1316) 2023-02-26 22:35:04 -08:00
forefrontai.md Add GooseAI, CerebriumAI, Petals, ForefrontAI (#981) 2023-02-13 21:20:19 -08:00
google_search.md docs: small typo google_search.md (#692) 2023-01-22 13:09:15 -08:00
google_serper.md Make Tools own model, add ToolKit Concept (#1095) 2023-02-18 13:40:43 -08:00
gooseai.md Add GooseAI, CerebriumAI, Petals, ForefrontAI (#981) 2023-02-13 21:20:19 -08:00
graphsignal.md [DOCS] Assorted wording, punctuation, and consistency revisions (#1443) 2023-03-08 20:16:09 -08:00
hazy_research.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
helicone.md [DOCS] Assorted wording, punctuation, and consistency revisions (#1443) 2023-03-08 20:16:09 -08:00
huggingface.md improve docs for indexes (#1146) 2023-02-19 23:14:50 -08:00
modal.md Add Writer, Banana, Modal, StochasticAI (#1270) 2023-02-24 06:58:58 -08:00
nlpcloud.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
openai.md improve docs for indexes (#1146) 2023-02-19 23:14:50 -08:00
opensearch.md Add Support for OpenSearch Vector database (#1191) 2023-02-20 18:39:34 -08:00
petals.md Update petals.md (#1225) 2023-02-22 10:34:16 -08:00
pinecone.md Fix link to Pinecone notebook (#1492) 2023-03-07 15:24:03 -08:00
promptlayer.md Harrison/prompt layer (#1547) 2023-03-08 21:24:27 -08:00
runhouse.md Harrison/updating docs (#1196) 2023-02-20 22:54:26 -08:00
searx.md searx: add install instructions, update doc and notebooks (#1420) 2023-03-03 20:57:50 -08:00
serpapi.md docs: small typo on serpapi.md (#693) 2023-01-22 13:10:24 -08:00
stochasticai.md Add Writer, Banana, Modal, StochasticAI (#1270) 2023-02-24 06:58:58 -08:00
unstructured.md feat: allow the unstructured kwargs to be passed in to Unstructured document loaders (#1667) 2023-03-14 18:15:28 -07:00
weaviate.md improve docs for indexes (#1146) 2023-02-19 23:14:50 -08:00
wolfram_alpha.md Harrison/wolfram alpha (#579) 2023-01-11 05:52:19 -08:00
writer.md Add Writer, Banana, Modal, StochasticAI (#1270) 2023-02-24 06:58:58 -08:00