File size: 3,822 Bytes
944aab6
3f62146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
944aab6
 
 
3f62146
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
retriverText = """ This microservice integrates with the vector database to retrieve semantically relevant documents,\
                        with optional reranking for precision, ready for seamless use in ChaBo RAG workflows. 

                        # Retriever and Reranker Microservice on Hugging Face Spaces 

                        [ChaBo_Retrieval](https://huggingface.co/spaces/GIZ/chatfed_retriever0.3) hosts a Retrieval and Reranker mciroservice.\
                        Some of key feature of Retrieval service are:
                        - The embedding of the user query is done by retriever itself using Sentence-Transformer.
                        - ReRanker is available as optional component.
                        - This is rate determining step as the emedding of user query can be compute intensive if using dedicated model.
                        - Model config, Qdrant server url and other params can be set through \
                            [params.cfg](https://huggingface.co/spaces/GIZ/chatfed_retriever0.3/blob/main/params.cfg)
                        
                        ```
                        [vectorstore]
                        # Qdrant-Server usage:
                        PROVIDER = qdrant
                        URL = giz-chatfed-qdrantserver.hf.space  
                        COLLECTION_NAME = EUDR

                        [embeddings]
                        MODEL_NAME = BAAI/bge-m3

                        [retriever]
                        TOP_K = 10
                        SCORE_THRESHOLD = 0.6

                        [reranker]
                        MODEL_NAME = BAAI/bge-reranker-v2-m3
                        TOP_K = 10
                        ENABLED = true
                        # use this to scale out the total docs retrieved prior to reranking (i.e. retriever top_k * TOP_K_SCALE_FACTOR)
                        TOP_K_SCALE_FACTOR = 2
                        ```
                        
                        **API documentation**: 1 API Endpoint
                        
                        ### api_name: /retrieve

                        Params:
                        - query(str): Required
                        - collection_name(str): collection_name in the Qdrant server which need to be queried. Defualts to None.
                        - filter_metadata(dict): metadata filtering for Qdrant vector store which will be 
                                                applied to the collection mentioned above. Defuals to None

                        Returns: List of retrieved context along with metadata as string, 
                        where each context is dict with two key 'answer' and 'answer_metadata'
                        
                        **How to Connect**

                        ```python
                        from gradio_client import Client
                        # Replace with your actual Space URL (e.g., https://your-username-retriever_space.hf.space)
                        retriever_url  = "https://giz-chatfed-retriever0-3.hf.space/"
                        client = Client(retriever_url)
                        result = client.predict(
                                query="What is Circular Economy",
                                collection_name="Humboldt",
                                filter_metadata=None,
                                api_name="/retrieve"
                        )
                        ```
                        For more info on Retriever and code base visit the following links:
                        - ChaBo_Retriever : [**ReadMe**](https://huggingface.co/spaces/GIZ/chatfed_retriever0.3/blob/main/README.md)
                        - ChaBo_Retriever: [**Codebase**](https://huggingface.co/spaces/GIZ/chatfed_retriever0.3/tree/main)"""