langchain/docs/modules
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
..
agents Harrison/convo agent (#1642) 2023-03-14 09:42:24 -07:00
chains Harrison/agent eval (#1620) 2023-03-14 12:37:48 -07:00
chat Remove outdated code from Chat VectorDB QA example (#1670) 2023-03-14 18:13:51 -07:00
document_loaders feat: allow the unstructured kwargs to be passed in to Unstructured document loaders (#1667) 2023-03-14 18:15:28 -07:00
indexes feat: add redisearch vectorstore (#1307) 2023-03-14 18:06:03 -07:00
llms (rfc) chat models (#1424) 2023-03-06 08:34:24 -08:00
memory Docs: Fix typo in memory/key_concepts.md (#1671) 2023-03-14 18:12:01 -07:00
prompts bump version to 109 (#1646) 2023-03-13 15:52:35 -07:00
utils changed requests.run to requests.get (#1485) 2023-03-07 21:10:23 -08:00
agents.rst Documentation: Minor typo fixes (#1327) 2023-02-27 14:40:43 -08:00
chains.rst Documentation: Minor typo fixes (#1327) 2023-02-27 14:40:43 -08:00
chat.rst (rfc) chat models (#1424) 2023-03-06 08:34:24 -08:00
document_loaders.rst Harrison/unstructured support (#903) 2023-02-05 23:02:07 -08:00
indexes.rst improve docs for indexes (#1146) 2023-02-19 23:14:50 -08:00
llms.rst Fix minor error in LLM documentation (#602) 2023-01-12 18:16:32 -08:00
memory.rst Harrison/memory refactor (#1478) 2023-03-07 07:59:37 -08:00
prompts.rst Feature: linkcheck-action (#534) (#542) 2023-01-04 21:39:50 -08:00
state_of_the_union.txt Docs refactor (#480) 2023-01-02 08:24:09 -08:00
utils.rst Feature: linkcheck-action (#534) (#542) 2023-01-04 21:39:50 -08:00