pdf-file.mdx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ---
  2. title: '📰 PDF'
  3. ---
  4. You can load any pdf file from your local file system or through a URL.
  5. ## Usage
  6. ### Load from a local file
  7. ```python
  8. from embedchain import App
  9. app = App()
  10. app.add('/path/to/file.pdf', data_type='pdf_file')
  11. ```
  12. ### Load from URL
  13. ```python
  14. from embedchain import App
  15. app = App()
  16. app.add('https://arxiv.org/pdf/1706.03762.pdf', data_type='pdf_file')
  17. app.query("What is the paper 'attention is all you need' about?", citations=True)
  18. # Answer: The paper "Attention Is All You Need" proposes a new network architecture called the Transformer, which is based solely on attention mechanisms. It suggests that complex recurrent or convolutional neural networks can be replaced with a simpler architecture that connects the encoder and decoder through attention. The paper discusses how this approach can improve sequence transduction models, such as neural machine translation.
  19. # Contexts:
  20. # [
  21. # (
  22. # 'Provided proper attribution is ...',
  23. # {
  24. # 'page': 0,
  25. # 'url': 'https://arxiv.org/pdf/1706.03762.pdf',
  26. # 'score': 0.3676220203221626,
  27. # ...
  28. # }
  29. # ),
  30. # ]
  31. ```
  32. We also store the page number under the key `page` with each chunk that helps understand where the answer is coming from. You can fetch the `page` key while during retrieval (refer to the example given above).
  33. <Note>
  34. Note that we do not support password protected pdf files.
  35. </Note>