Update README.md

#2
by grasimus - opened
Files changed (1) hide show
  1. README.md +31 -78
README.md CHANGED
@@ -12,107 +12,62 @@ pinned: false
12
 
13
 
14
 
15
- # Interview Q and A Dataset
16
-
17
- I built this dataset to solve a recurring problem I observed in data science and engineering education: the lack of realistic, challenging interview material for practice. Every interview is a performance, and to perform well, candidates need access to questions that reflect the actual hiring landscape across various industries and roles.
18
-
19
- To create this material, I generated the entire dataset locally on my PC using an NVIDIA RTX 3080 GPU running Ollama. Running it locally gave me complete control over the generation pipeline without rate limits or data privacy concerns. I employed advanced prompt engineering techniques, including persona adoption, few-shot prompting, and strict JSON output formatting. I instructed the local language model to act as a senior talent acquisition specialist, dynamically injecting highly elaborated prompts with varying combinations of role, industry sector, interviewer persona, and difficulty tier. My goal was to guarantee that a Junior HR Specialist in Healthcare interviewed by a "Supportive" persona received a completely different and appropriate question compared to a Senior Data Scientist in Cybersecurity facing an "Aggressive" technical interviewer. The result is a structured, balanced question bank containing twenty thousand unique interview pairs.
20
-
21
- ## Dataset Structure
22
-
23
- The dataset contains the following data structure:
24
-
25
- | Column | Type | Description |
26
- |---|---|---|
27
- | `question` | string | The interview question generated by the LLM |
28
- | `answer` | string | A model gold-standard answer |
29
- | `keywords` | string | Domain-specific searchable keywords |
30
- | `role` | string | Job title (e.g., Data Scientist, Software Engineer) |
31
- | `sector` | string | Industry sector (e.g., Finance, Healthcare) |
32
- | `interview_stage` | string | The type of interview round |
33
- | `interviewer` | string | The persona/tone of the interviewer |
34
- | `question_category` | string | Sub-category of the question (e.g., System Design) |
35
- | `question_level` | string | Difficulty / Seniority Level |
36
-
37
- After generating the data, I conducted a rigorous Exploratory Data Analysis to validate the quality and diversity of my synthetic dataset.
38
-
39
- ## Exploratory Data Analysis
40
-
41
- ### Categorical Distributions
42
-
43
- ![Categorical Distributions](eda_categorical_distributions.png)
44
-
45
- I began by checking the categorical variables to ensure balance across the dataset. First, I looked at the difficulty distribution across different seniority levels and learned that the model successfully balanced Easy, Medium, and Hard questions across all seniority tiers. Hard questions were slightly rarer, which perfectly mirrors real-world hiring pipelines where challenging questions are reserved for specific technical deep-dives. I also analyzed the distribution of question categories against interview types and discovered that the dataset did not over-represent any single skill. The questions were broadly distributed across twenty different categories, providing comprehensive coverage. Lastly, I verified the industry sector coverage and found a near-uniform distribution across all fourteen targeted sectors. This was a critical lesson: a dataset skewed entirely toward technology companies would be useless for a candidate applying to a hospital or a bank. My data remains truly industry-agnostic.
46
-
47
- ### Text Length Analysis
48
-
49
- ![Text Length Analysis](eda_text_length_analysis.png)
50
-
51
- I also needed to ensure the text itself felt natural, so I examined the text length distributions. I observed that the generated questions were concise and direct, while the answers provided enough depth to demonstrate expertise without turning into massive walls of text.
52
-
53
- ### Keyword Presence
54
-
55
- ![Keyword Presence](eda_keyword_presence.png)
56
-
57
- To understand the technical vocabulary that dominated the dataset, I visualized the keyword presence. I observed that the language model successfully injected specific, relevant technical terms into the questions, avoiding overly generic fluff. This confirmed that the prompt engineering effectively anchored the questions in realistic technical scenarios.
58
-
59
- ### Near Duplicate Detection
60
-
61
- ![Near Duplicate Detection](eda_near_duplicates.png)
62
-
63
- A common pitfall with synthetic data is repetitive generation. To test for this, I implemented a near-duplicate detection script using TF-IDF cosine similarity. I was thrilled to see that almost all pairwise similarities were close to zero. There were absolutely no pairs crossing the high similarity thresholds, giving me mathematical proof that my dataset was clean and unique.
64
-
65
- ### Role Keyword Alignment
66
 
67
- ![Role Keyword Alignment](eda_role_keyword_alignment.png)
68
 
69
- To take the analysis deeper, I designed a test to check the role and keyword alignment. I wanted to know if a Frontend Developer question actually contained frontend terminology. I initially found that some roles scored poorly because my keyword dictionary was too generic. Once I updated my script to search for actual technical domain words, the alignment rates soared. This taught me the importance of tailoring validation rules to the specific semantic domain being measured.
 
 
70
 
71
- ### Sentiment Analysis
72
 
73
- ![Sentiment Analysis](eda_sentiment_analysis.png)
74
 
75
- Finally, I wanted to validate whether the model respected the "interviewer persona" I requested in my prompt. I used sentiment analysis to check the tone of the questions. I had to truncate the Y-axis labels because the prompt descriptions were too long and squashed the graph. Once fixed, the plot clearly showed that the "Aggressive" personas had distributions shifted toward negative polarity, while the "Friendly" personas were noticeably positive. This confirmed that my prompt engineering successfully altered the behavior and tone of the language model.
76
 
77
- With the data fully validated and explored, I am now moving forward to embed this dataset and build a recommendation engine.
78
 
 
 
 
79
 
 
80
 
81
- ## 3. Embedding Model Selection
82
- To determine the most effective retrieval model for the application, three different open-source embedding models from Hugging Face were rigorously evaluated: `all-MiniLM-L6-v2`, `bge-small-en-v1.5`, and `e5-small-v2`.
83
 
 
84
 
85
- ![quality_vs_speed_evaluaation](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/J6pWxJRDnjUYRQ0jyyF8s.png)
86
 
 
87
 
88
- ![performance_compare](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/lOwBF7gaeFhsce5QH_tt2.png)
89
 
 
90
 
91
- **Observation:**
92
- The evaluation measured both execution speed and retrieval performance (Precision@1, Precision@5, and Mean Reciprocal Rank).
93
- * `all-MiniLM-L6-v2` proved to be the fastest but lacked the semantic depth required for complex interview scenarios.
94
- * `e5-small-v2` consistently outperformed the others in semantic retrieval quality, achieving the highest Mean Reciprocal Rank (MRR: 0.30) and Precision@1 (0.18).
95
 
96
- **Conclusion:** Despite a slightly longer execution time, `intfloat/e5-small-v2` was selected as the core embedding model due to its superior ability to capture the nuanced context of technical interview questions. All 18,144 questions were encoded and saved to an `.npy` vector database.
97
 
98
- ---
99
 
100
- ## 4. Embeddings Analysis & Clustering
101
- To validate that the chosen E5 model mathematically understands the interview domain, the 384-dimensional vectors were analyzed using dimensionality reduction (t-SNE/PCA) and clustering algorithms.
102
 
103
  ![tSNE_projection](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/87YXdM2-F10u7gTdShgMz.png)
104
 
105
- **Dimensionality Reduction:** The t-SNE projections demonstrate how the models group questions by their true categories. The E5 model (right) shows distinct, organic clustering of topics like "Communication & Soft Skills" versus hard technical categories, validating its semantic mapping.
 
 
106
 
107
  ![SEMANTIC](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/rZ84igc2uMRVGqBcaE8g0.png)
108
 
109
- **Hierarchical Semantic Taxonomy:**
110
- Using Ward's Linkage Variance, a hierarchical dendrogram was generated from the E5 embeddings. The algorithm automatically discovered the fundamental pillars of a tech interview without being provided any labels. It organically grouped the categories into distinct "branches":
111
- 1. **Behavioral & HR:** Culture Fit, Soft Skills, and Salary naturally clustered together.
112
- 2. **Core Engineering:** Coding, System Design, and Tools & Frameworks formed a distinct technical branch.
113
- 3. **Operational Dynamics:** Incident Response, Conflict Resolution, and Cross-Team Work formed a behavioral-operational cluster.
114
 
115
- This proves the retrieval system searches within a highly structured, semantically logical vector space.
116
 
117
  ---
118
 
@@ -125,5 +80,3 @@ The application utilizes a Vector-Based Retrieval strategy to recommend the most
125
  3. **Query Embedding:** The input query is passed through the selected `e5-small-v2` model, converting it into a 384-dimensional query vector.
126
  4. **Vector Similarity Search:** The system computes the **Cosine Similarity** between the user's query vector and the pre-computed question embeddings database.
127
  5. **Retrieval:** The system identifies the vector with the highest similarity score (argmax) and retrieves the exact matching interview scenario.
128
-
129
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
12
 
13
 
14
 
15
+ ## 3. Embedding Model Selection
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ To power the retrieval engine, I evaluated three open-source, 384-dimensional sentence-embedding models from Hugging Face: `all-MiniLM-L6-v2`, `BAAI/bge-small-en-v1.5`, and `intfloat/e5-small-v2`. The evaluation ran on a random sample of 2,500 questions and measured three things:
18
 
19
+ 1. **Encoding speed** β€” how long it takes to embed the sample.
20
+ 2. **Semantic separability** β€” Silhouette Score (cosine) of the embedding space against the 16 true question categories.
21
+ 3. **Retrieval quality** β€” Precision@1, Precision@5, and Mean Reciprocal Rank (MRR), where a retrieved question counts as relevant if it belongs to the same category as the query.
22
 
23
+ One implementation detail worth noting: `e5-small-v2` is an asymmetric retrieval model and requires a `query: ` prefix on queries and a `passage: ` prefix on documents β€” without them its performance collapses. These prefixes were applied throughout the evaluation and the application.
24
 
25
+ ![quality_vs_speed_evaluation](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/J6pWxJRDnjUYRQ0jyyF8s.png)
26
 
27
+ ![performance_compare](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/lOwBF7gaeFhsce5QH_tt2.png)
28
 
29
+ **Observations:**
30
 
31
+ * **Speed:** `all-MiniLM-L6-v2` was by far the fastest (~28s for 2,500 questions), while `e5-small-v2` was the slowest (~84s, roughly 3Γ— longer).
32
+ * **Semantic separability:** all three silhouette scores were slightly negative β€” expected, since interview categories share a great deal of vocabulary and overlap heavily in meaning β€” but `e5-small-v2` scored best (βˆ’0.033), ahead of `bge-small-en-v1.5` (βˆ’0.040) and `all-MiniLM-L6-v2` (βˆ’0.046).
33
+ * **Retrieval:** `e5-small-v2` won on all three metrics: Precision@1 = 0.18, Precision@5 = 0.16, MRR = 0.30. Interestingly, `all-MiniLM-L6-v2` came second (P@1 = 0.16, MRR = 0.28) and `bge-small-en-v1.5` last (P@1 = 0.15, MRR = 0.26), so raw model size was not the deciding factor. For context, these are strict proxy metrics β€” a match counts only if the retrieved question shares the exact category β€” and with 16 categories a random ranker would score P@1 β‰ˆ 0.06, so the winner performs roughly 3Γ— better than chance.
34
 
35
+ **Conclusion:** `intfloat/e5-small-v2` won both quality evaluations (separability and retrieval), so despite being the slowest of the three, it was selected as the core embedding model. All 20,444 questions were then encoded with the `passage: ` prefix, L2-normalized, and saved as an `.npy` vector store that the application loads at startup.
36
 
37
+ ---
 
38
 
39
+ ## 4. Embeddings Analysis & Clustering
40
 
41
+ To validate that the chosen model organizes the interview domain in a meaningful way, the embedding space was analyzed with three complementary techniques: K-Means clustering with the Elbow Method, t-SNE projection, and hierarchical clustering.
42
 
43
+ ### K-Means & the Elbow Method
44
 
45
+ ![elbow_method](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/LQcobbqST6PAjn1-bVeMN.png)
46
 
47
+ For each of the three candidate models, K-Means was fitted for K = 2 to 15 and the inertia (sum of squared distances) was plotted. The curves decline smoothly without a sharp elbow β€” another sign that interview questions form a continuum rather than isolated islands β€” but the bend suggested a different natural granularity per model: **K = 10** for MiniLM, **K = 8** for BGE, and **K = 6** for E5. Each model was then re-clustered at its own optimal K and projected to 2D (TruncatedSVD) for visual comparison:
48
 
 
 
 
 
49
 
50
+ ![optimized_clusters](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/i7JxLx4iJJOgYMd2-8Bet.png)
51
 
52
+ The E5 map shows the cleanest macro-structure: even at the smallest K, its clusters occupy distinct, coherent regions of the projection instead of interleaving.
53
 
54
+ ### t-SNE Projection (True Categories)
 
55
 
56
  ![tSNE_projection](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/87YXdM2-F10u7gTdShgMz.png)
57
 
58
+ To check how well each embedding space respects the *true* labels, the five most frequent question categories were projected with t-SNE (a non-linear method better suited to deep embeddings than PCA) and colored by their real category. As expected from the silhouette analysis, the categories are not linearly separable in any of the three spaces β€” interview questions genuinely blend topics (a "Coding & Problem Solving" question in FinTech shares vocabulary with "Tools & Frameworks"). However, clear **local neighborhood structure** is visible, and it is strongest in the E5 panel (right): "Prioritization Under Pressure" concentrates into a dense central region and "Tools & Frameworks" forms distinct pockets. This local coherence is exactly what a nearest-neighbor retrieval engine relies on, and it is consistent with E5 winning the Precision/MRR comparison.
59
+
60
+ ### Hierarchical Semantic Taxonomy
61
 
62
  ![SEMANTIC](https://cdn-uploads.huggingface.co/production/uploads/69d7aa949910f34b03f98b9d/rZ84igc2uMRVGqBcaE8g0.png)
63
 
64
+ Finally, a mean (centroid) embedding was computed for each of the 16 question categories, L2-normalized, and clustered hierarchically using **Ward's linkage**. The category labels only define the 16 groups β€” the *relationships between them* are discovered purely from the geometry of the embedding space. The resulting dendrogram organizes the interview domain into three interpretable branches:
65
+
66
+ 1. **Behavioral & HR:** "Culture Fit & Values", "Salary & Expectations", "Communication & Soft Skills", and "Business Impact & Metrics" merge together at low distance.
67
+ 2. **Core Engineering:** "Coding & Problem Solving", "System Design & Architecture", "Scalability & Growth Planning", and "Innovation & Emerging Tech" form a distinct technical branch. Notably, "Motivation & Career Goals" attaches to this branch via "Tools & Frameworks" β€” the model apparently associates career-growth questions with technology-stack questions, a genuinely surprising discovery.
68
+ 3. **Operational & Situational:** "Incident Response & Ownership", "Prioritization Under Pressure", "Collaboration & Cross-Team Work", and "Conflict Resolution" cluster together with "Debugging & Troubleshooting" and "Technical Roadmap & Strategy" β€” the "how do you act under real conditions" side of interviewing.
69
 
70
+ The fact that this taxonomy matches how humans intuitively divide interviews β€” HR vs. hard skills vs. situational behavior β€” without ever being told those relationships confirms that the retrieval system operates in a semantically structured vector space.
71
 
72
  ---
73
 
 
80
  3. **Query Embedding:** The input query is passed through the selected `e5-small-v2` model, converting it into a 384-dimensional query vector.
81
  4. **Vector Similarity Search:** The system computes the **Cosine Similarity** between the user's query vector and the pre-computed question embeddings database.
82
  5. **Retrieval:** The system identifies the vector with the highest similarity score (argmax) and retrieves the exact matching interview scenario.