# Human-Centered AI for Migrant Integration Through LLM and RAG Optimization
## 5 Materials and Methods
### Experiment  
The experimentation was conducted following the proposed methodology. The details of the experimental dataset are provided in Section 5.2. For each parameter, at least five different hyperparameter combinations were tested, resulting in a total of 125 combinations evaluated. The values of the hyperparameters were selected in accordance with the acceptable ranges established by the state of the art in the field.  
The parameters used in the experimentation--chunk size, top-K, and temperature--are critical in RAG systems. An exploratory study was conducted to identify the chunk sizes which would improve the performance and accuracy of a RAG system [42]. It was determined that smaller chunks allow for more precise retrieval of specific information, although they may lose important context. In contrast, larger chunks maintain more context but may dilute retrieval accuracy. Chunk sizes of 50, 100, 300, 500, and 1000 were evaluated, which were selected for their balance between detail granularity and processing efficiency. The chunk sizes did not exceed the limits of the models used. Smaller chunk sizes (50 or 100) improved retrieval accuracy by isolating specific details, while larger chunk sizes (500 or 1000) enhanced performance by reducing the number of segments to index. These chunk sizes were subsequently applied in experiments to optimize both the accuracy and efficiency of the system. The top-K, tested with values of 1, 2, 5, 8, and 10, specifies the number of documents or fragments retrieved to generate a response, with higher values providing more context at the cost of increased complexity and processing times. The temperature, ranging from 0.1 to 0.9, controls the level of randomness in the generated responses, where higher values encourage greater diversity and creativity, while lower values promote more deterministic and conservative responses.  
In the experimentation, various models integrated into the PoC were utilized. These models were employed for different tasks within the system, including text generation, semantic similarity evaluation, stereotype and hate speech detection, and the creation of embeddings for information retrieval. The coordination of these models allowed for a comprehensive and diverse analysis of the processed texts. For text generation, the Meta-Llama-3-8B-Instruct model from the causal language model was used. The all-MiniLM-L6-v2 model was used to calculate the semantic similarity between the given response and the expected response. The Narrativa/distilroberta-finetuned-stereotype-detection model was employed as a text classification model adjusted for stereotype detection. For the detection of hate speech in Spanish, the pretrained Hate-speech-CNERG/dehatebert-mono-spanish model was used. The BAAI/bge-base-en-v1.5 model was employed as an embeddings model for indexing and similarity-based searching. All of these models are available on Hugging Face's website [70].  
In the selection of optimal hyperparameter configurations for the RAG system within an HCAI framework, MCDM methods were utilized, specifically the RIM, TOPSIS, and VIKOR [64; 65; 66].  
A total of 125 hyperparameter configurations were defined by aggregating metrics using the median of the results obtained from 91 questions and their corresponding answers. These configurations constitute the alternatives evaluated using MCDM methods. To apply these methods, a decision matrix was established, along with the weights of the criteria, the typology of the criteria, and the specific details for each method.