Patrefans
echohive42 from patreon
echohive42 patreon

How to install Unstructured for Langchain Document loaders

🕑 Added 2023-02-21 23:40:29 +0000 UTC

Comments

Echo Hive

Hi Patrick. I think the problem can result from two things. Tesseract which does OCR(optical character recognition) and/or Detecteon which detects the layout in an image like object. Unless they update those libraries and Untstuctured implements their latest version, this problem will persist. You can take a look at other PDF readers and see if they can extract the text better. If there is such a package, this approach should work. You just would have to write a logic to deal with multiple pdf files. I hope this is helpful.

Patrick Young

Hi everyone, I followed this tutorial and now I have a program that runs in vscode on windows11. It uses document loader to reads text from URLs, images and all regular files like txt, md, py, etc. It mostly works, but images can sometimes be problematic. E.g., if I load a two page infographic .jpg with UnstructuredFileLoader() it will only extract some of the text from the image. IDK whether UnstructuredFileLoader is causing the issue. Or, is it an image segmentation problem (Detectron2)? Other possibilities: (LayoutParser? Tesseract? PyTesseract? Opencv-python? Torchvision? Trawling for suggestions. Here, there, everywhere. Anyone?

Echo Hive

Thank you very much for sharing your own installation experience and tips!

Echo Hive

I haven’t used unstructured much. But it is default loader for almost all document loaders in langchain. So I wanted to make a video about how to install it.

Patrick Young

ps Echohive do you use it a lot? What sort of use cases benefit?

Patrick Young

Bingo. Works like a charm! Joined Patreon. Thx Echohive'! NB instruction post from patreon wouldn't work for me. Most problems are caused by package incompatibility. NB my system: Windows 11 home system running on an Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz with an nvidia RTX 3050 GPU. As others have found I also ran into probs pip installing unstructured[local-inference], pycotools errors and ninja build compilation errors when trying to get detectron2 up & running. You need C++ build tools - install from visual studio). Also I installed detectron2 *first* using a .yml I found on stackoverflow because I realised that using the latest versions of Python, dectectron2, pytorch wouldn't work. I could get it to work by using python=3.8, cudatoolkit=11.0, pytorch==1.7.1 and quite an old version of detectron2 from the facebookresearch/detectron2 git . If Echohive, or anyone else wants the .yml file see step 2 on https://stackoverflow.com/questions/60631933/install-detectron2-on-windows-10 in the answer posted by DV82XL user:5752730.

Echo Hive

Thank you for sharing that! πŸ™Œ

Patrick Young

you need to install microsoft build tools. I installed visual studio C++ development module to get this & then it build pycotools

Echo Hive

Make sure to upgrade setup tools and upgrade pip before pip installing: pip install --upgrade setuptools python.exe -m pip install --upgrade pip

Kris Wilkinson

Im about to attempt to tackle the problem with GPTChat, but thought I'd ask this awesome community alongside.

Kris Wilkinson

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pycocotools Successfully built unstructured-inference python-docx python-pptx unstructured iopath antlr4-python3-runtime Failed to build pycocotools ERROR: Could not build wheels for pycocotools, which is required to install pyproject.toml-based projects

Kris Wilkinson

Im coming across the below error whilst attempting to pip install unstructured[local-inference]

Kris Wilkinson

This just may be the holy grail for self-taught developers like me as this is the part that takes the most skill, and most time to understand!

Echo Hive

You can definitely try although I am not sure if they will work. My hunch is that they should.

Vipin Kasarla

Do you think I can use https://llamahub.ai/ functions as a loader, and use it as input to LangChain? I find using lLamhub loaders and GPTIndex much more simpler.... and it has pdf, docx and many other loaders (the websie says it can be used with Langchan too !!!

Echo Hive

It probably won’t work with MS word documents because as far as I could tell you need β€œLibreoffice” installed for that. Which seemed to me like it was complicated.

Vipin Kasarla

Thanks for this post, because I want to use this with your previous post on ChatGPT with documents. Q: Would this also work with MS Word documents? (If not how I make it work?)


More Creators