pdf-file.mdx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ---
  2. title: '📰 PDF'
  3. ---
  4. You can load any pdf file from your local file system or through a URL.
  5. ## Setup
  6. Install the following packages for loading youtube videos which help in transcription.
  7. ```bash
  8. pip install pytube youtube-transcript-api
  9. ```
  10. ## Usage
  11. ### Load from a local file
  12. ```python
  13. from embedchain import App
  14. app = App()
  15. app.add('/path/to/file.pdf', data_type='pdf_file')
  16. ```
  17. ### Load from URL
  18. ```python
  19. from embedchain import App
  20. app = App()
  21. app.add('https://arxiv.org/pdf/1706.03762.pdf', data_type='pdf_file')
  22. app.query("What is the paper 'attention is all you need' about?", citations=True)
  23. # 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.
  24. # Contexts:
  25. # [
  26. # (
  27. # 'Provided proper attribution is ...',
  28. # {
  29. # 'page': 0,
  30. # 'url': 'https://arxiv.org/pdf/1706.03762.pdf',
  31. # 'score': 0.3676220203221626,
  32. # ...
  33. # }
  34. # ),
  35. # ]
  36. ```
  37. 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).
  38. <Note>
  39. Note that we do not support password protected pdf files.
  40. </Note>