|
| 1 | +# llama.cpp/examples/retrieval |
| 2 | + |
| 3 | +Demonstration of simple retrieval technique based on cosine similarity |
| 4 | + |
| 5 | +More info: |
| 6 | +https://github.com/ggerganov/llama.cpp/pull/6193 |
| 7 | + |
| 8 | +### How to use |
| 9 | + |
| 10 | +`retieval.cpp` has parameters of its own: |
| 11 | +- `--context-file`: file to be embedded - state this option multiple times to embed multiple files |
| 12 | +- `--chunk-size`: minimum size of each text chunk to be embedded |
| 13 | +- `--chunk-separator`: STRING to divide chunks by. newline by default |
| 14 | + |
| 15 | +`retrieval` example can be tested as follows: |
| 16 | + |
| 17 | +```bash |
| 18 | +make -j && ./retrieval --model ./models/bge-base-en-v1.5-f16.gguf --top-k 3 --context-file README.md --context-file License --chunk-size 100 --chunk-separator . |
| 19 | +``` |
| 20 | + |
| 21 | +This chunks and embeds all given files and starts a loop requesting query inputs: |
| 22 | + |
| 23 | +``` |
| 24 | +Enter query: |
| 25 | +``` |
| 26 | + |
| 27 | +On each query input, top k chunks are shown along with file name, chunk position within file and original text: |
| 28 | + |
| 29 | +``` |
| 30 | +Enter query: describe the mit license |
| 31 | +batch_decode: n_tokens = 6, n_seq = 1 |
| 32 | +Top 3 similar chunks: |
| 33 | +filename: README.md |
| 34 | +filepos: 119 |
| 35 | +similarity: 0.762334 |
| 36 | +textdata: |
| 37 | +png) |
| 38 | +
|
| 39 | +[](https://opensource.org/licenses/MIT) |
| 40 | +
|
| 41 | +[Roadmap](https://github. |
| 42 | +-------------------- |
| 43 | +filename: License |
| 44 | +filepos: 0 |
| 45 | +similarity: 0.725146 |
| 46 | +textdata: |
| 47 | +MIT License |
| 48 | +
|
| 49 | +Copyright (c) 2023 Georgi Gerganov |
| 50 | +
|
| 51 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 52 | +of this software and associated documentation files (the "Software"), to deal |
| 53 | +in the Software without restriction, including without limitation the rights |
| 54 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 55 | +copies of the Software, and to permit persons to whom the Software is |
| 56 | +furnished to do so, subject to the following conditions: |
| 57 | +
|
| 58 | +The above copyright notice and this permission notice shall be included in all |
| 59 | +copies or substantial portions of the Software. |
| 60 | +-------------------- |
| 61 | +filename: README.md |
| 62 | +filepos: 9178 |
| 63 | +similarity: 0.621722 |
| 64 | +textdata: |
| 65 | +com/cztomsik/ava) (MIT) |
| 66 | +- [ptsochantaris/emeltal](https://github.com/ptsochantaris/emeltal) |
| 67 | +- [pythops/tenere](https://github. |
| 68 | +-------------------- |
| 69 | +``` |
0 commit comments