jansowa commited on
Commit
387f1e8
·
verified ·
1 Parent(s): fa79b35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +88 -49
app.py CHANGED
@@ -164,7 +164,11 @@ st.markdown("""
164
  tab1, tab2 = st.tabs([RESULTS_COLUMN_NAME, "Description"])
165
 
166
  with tab1:
167
- st.write("This benchmark is designed to evaluate the ability of language models to correctly interpret complex Polish texts, including sarcasm, phraseological compounds, and implicatures. Models are assessed not only on traditional sentiment analysis but also on their ability to understand and interpret more complex language forms. The focus is on how well models can uncover the intended meaning in texts that require going beyond literal word meanings to recognize deeper, context-dependent interpretations.")
 
 
 
 
168
 
169
  # Prepare data
170
  data = load_data('data.json')
@@ -364,60 +368,91 @@ with tab1:
364
  with tab2:
365
  st.markdown("""
366
  ### <span style='text-decoration: #FDA428 wavy underline;'>**Cause of Creation**</span>
367
- 1. **Need**: Models face significant challenges when dealing with understanding complex, context-reliant texts that involve meanings implied beyond the literal content of a statement. Such cases include sarcasm, implicatures, and phraseological compounds.
368
- Traditional sentiment classifiers typically rely on word-based features (e.g., identifying positive or negative words) to assess sentiment. However, with sarcasm, the literal meaning of words often contradicts the intended sentiment, making it difficult for models to accurately gauge tone. Sarcasm's context-dependence further complicates matters, as these classifiers typically lack the ability to grasp nuanced cues in context, especially when sarcasm is subtle.
369
- Similarly, classifiers struggle with implicatures, where the underlying intent is implied rather than explicitly stated. Here, models fail to capture the full sentiment because they rely heavily on surface-level words, missing the non-literal meaning that often drives the sentiment.
370
- Phraseological compounds add another layer of difficulty. These are fixed or semi-fixed expressions whose meanings cannot be directly inferred from the individual words. Language models, trained on word-level patterns, often misinterpret these expressions because they fail to recognize the idiomatic or non-literal meaning, leading to inaccurate sentiment analysis.
371
- In addition to sentiment analysis, we decided to include the understanding of more complex texts in the benchmark, which was measured by the ability to uncover the intended meaning.
 
 
 
 
 
 
 
 
 
372
  ### <span style='text-decoration: #FDA428 wavy underline;'>**Dataset Information**</span>
373
- The dataset contains 200 examples, all written in Polish. Each example consists of the following:
374
- - **Main Text**: This is a statement (often an opinion) on any topic that includes a certain type of implicature, often several simultaneously, such as sarcasm or phraseological compounds.
375
- - **Reference Sentiment**: The sentiment associated with the main text. We use three categories: negative, neutral, and positive. Ambiguous examples were labeled as "neutral" to exclude them from sentiment classification testing.
376
- - **Reference phraseological compounds**: A list of phraseological compounds found in the main text.
377
- - **Reference Explanation**: An explanation of the underlying intentions that the author of the main text might have had.
 
 
 
 
 
 
 
 
 
 
 
 
 
378
  ### <span style='text-decoration: #FDA428 wavy underline;'>**Evaluation Procedure**</span>
379
- We distinguish between two models in the evaluation process:
380
- - **Evaluated Model**: The model that performs specific tasks, is then assessed based on its performance, and added to a ranking.
381
- - **Judge Metamodel**: One of the currently strongest, most versatile LLMs.
382
- ### <span style='text-decoration: #FDA428 wavy underline;'>**GENERATING RESPONSES FROM THE EVALUATED MODEL**</span>
383
- 1. For each text in the dataset, the evaluated model was required to list the following in three points:
384
- - The sentiment (only positive/negative).
385
- - The underlying intentions of the author of the text.
386
- - All phraseological compounds present in the text along with their meanings in the given context.
387
- 2. No system prompt is used. The prompt provided to the evaluated model is written in Polish, as we are testing the models in this language. It contains:
388
- - **User Prompt**: 3 elements, each consisting of a header written in capital letters and content enclosed in triple quotes:
389
- - Information about the role of a careful linguist with extensive experience.
390
- - The instruction to perform the three previously described tasks.
391
- - The first example of a text that could be included in the dataset.
392
- - **Assistant Prompt**: A human-written example answer for the first example text.
393
- - **User Prompt**: A second example of a text that could be included in the dataset.
394
- - **Assistant Prompt**: A human-written example answer for the second example text.
395
- - **User Prompt**: The target text, based on which the evaluated model will be assessed.
396
- 3. The decision to split the examples into user prompts and assistant prompts was made due to the better results achieved by the vast majority of models. The two examples were selected based on diversity: one has a negative sentiment and several phraseological compounds, while the other is positive and lacks phraseological compounds.
397
- ### <span style='text-decoration: #FDA428 wavy underline;'>**GENERATING METAMODEL EVALUATIONS**</span>
398
- 1. The purpose of the metamodel is to return the following evaluations:
399
- - **Understanding of the Text**: A comparison of the evaluated model's response description to the reference explanation.
400
- - **Sentiment Analysis**: An optional evaluation, only if the reference sentiment is "positive" or "negative." We made this decision to exclude texts that people might interpret ambiguously.
401
- - **phraseological compounds**: The model is penalized for phrases not included in the reference phraseological compounds. In cases where there are no phraseological compounds, the highest score is awarded only if the model indicates the absence of such expressions — one point is deducted for each excess phrase until the score reaches zero.
402
- 2. Each evaluation is provided in JSON format. Example of a full response from the metamodel:
 
 
 
 
 
403
  ```json
404
  {"WYDŹWIĘK": "5"}
405
  {"OCENA": "4"}
406
  {"ZWIĄZKI": "3"}
407
  ```
408
- 3. The judge metamodel's prompt structure is similar to that of the evaluated model's prompt. No system prompt is used. The prompt includes:
409
- - **User Prompt**: 3 elements, each consisting of a header written in capital letters and content enclosed in triple quotes:
410
- - **Role**: A reliable assistant who adheres to the instructions and does not perform any other tasks, nor enters any additional text in the response.
411
- - **Task**: According to the description in point 1. The comparison of phraseological compounds has the most guidelines, so we noted that the model should focus on this as it is the most challenging step, and that its work will be evaluated based on this point.
412
- - The first example of a potential response from the evaluated model along with the references.
413
- - **Assistant Prompt**: An example response containing the evaluations.
414
- - **User Prompt**: A second example of a potential response from the evaluated model along with the references.
415
- - **Assistant Prompt**: An example response containing the evaluations for the second example.
416
- - **User Prompt**: The actual response from the evaluated model and the references on which the metamodel will base its evaluations included in the benchmark.
417
- 4. Here, the examples were also selected based on diversity. One includes a reference with a positive sentiment, while the other contains no reference sentiment at all (an example labeled as "neutral" in the dataset).
418
- 5. It is worth explaining why we chose this particular process for evaluating phraseological compounds. Initially, we intended to check only those phrases included in the reference and ignore others in the evaluation. Unfortunately, this procedure favored models that provided many phrases that were not phraseological compounds.
419
- Therefore, we decided to penalize models for phrases not included in the reference. We aimed to ensure that models were not penalized for providing phraseological compounds we had not included in the reference. After generating the responses, we collected phrases noted by several models and manually reviewed all references to identify phraseological compounds we might have missed.
420
- A similar procedure was applied to sentiment analysis—we listed all examples where several models consistently recorded a different sentiment than the reference and reconsidered whether the examples could be interpreted differently than initially assumed.
 
 
 
 
421
  """, unsafe_allow_html=True)
422
 
423
 
@@ -427,6 +462,8 @@ st.markdown("<hr style='border: 1px solid #A85E00;'>", unsafe_allow_html=True)
427
  st.markdown("""
428
  ### Authors:
429
  - [Jan Sowa](https://www.linkedin.com/in/janpiotrsowa) - leadership, writing texts, benchmark code
 
 
430
  - [Agnieszka Kosiak](https://www.linkedin.com/in/agn-kosiak/) - writing texts
431
  - [Magdalena Krawczyk](https://www.linkedin.com/in/magdalena-krawczyk-7810942ab/) - writing texts, labeling
432
  - [Marta Matylda Kania](https://www.linkedin.com/in/martamatyldakania/) - prompt engineering
@@ -435,8 +472,10 @@ st.markdown("""
435
  - [Szymon Baczyński](https://www.linkedin.com/in/szymon-baczynski/) - front-end / streamlit assistant
436
  - [Artur Słomowski](https://www.linkedin.com/in/arturslomowski/) - front-end / streamlit assistant
437
  - [Maria Filipkowska](https://www.linkedin.com/in/maria-filipkowska/) - writing text, linguistic support
 
 
438
  """)
439
 
440
  st.divider()
441
 
442
- # Run the app with `streamlit run your_script.py`
 
164
  tab1, tab2 = st.tabs([RESULTS_COLUMN_NAME, "Description"])
165
 
166
  with tab1:
167
+ st.markdown("""
168
+ This benchmark is designed to evaluate the proficiency of language models in accurately interpreting complex Polish texts. It comprises two distinct components:
169
+ 1. *Implicatures*: This part evaluates models on their capacity to interpret implied meanings, including sarcasm, idiomatic expressions, and varying levels of linguistic complexity. Beyond conventional sentiment analysis, models are specifically assessed for their ability to discern implicit meanings that extend beyond literal interpretations, requiring sensitivity to nuanced, context-dependent inferences.
170
+ 2. *Tricky Questions*: This section assesses the model's capability to accurately address challenging questions characterized by logical puzzles, semantic ambiguity, logical inconsistencies, absurdity, and humor. The emphasis here lies in evaluating the model's reasoning skills and flexibility in handling unconventional linguistic constructs.
171
+ """)
172
 
173
  # Prepare data
174
  data = load_data('data.json')
 
368
  with tab2:
369
  st.markdown("""
370
  ### <span style='text-decoration: #FDA428 wavy underline;'>**Cause of Creation**</span>
371
+ LLM models face multiple challenges that significantly impact their practical use. This benchmark has been created to comprehensively evaluate two distinct but equally critical aspects of their performance:
372
+ #### 1. **Implicatures and Phraseological Compounds**
373
+ Language models frequently struggle when interpreting complex, context-dependent meanings that extend beyond the literal interpretation of a text. Such linguistic phenomena include sarcasm, implicatures, and idiomatic or phraseological expressions.
374
+ - **Sarcasm:** Traditional sentiment analysis often fails on sarcastic statements because the literal meaning directly contradicts the intended sentiment. This context-dependence makes detection particularly difficult.
375
+ - **Implicatures:** These implied meanings, not explicitly stated, often elude models which rely heavily on surface-level text analysis.
376
+ - **Phraseological Compounds:** Fixed or semi-fixed expressions whose meanings can't be inferred from their individual components pose additional challenges, leading to inaccurate interpretation by models trained primarily on word-level semantics.
377
+ The goal of this part of the benchmark is thus to test the ability of LLMs to correctly interpret implied meanings, detect sarcasm, identify idiomatic phrases, and evaluate their overall text understanding capability beyond literal semantics.
378
+ #### 2. **Tricky Questions and Hallucination Detection**
379
+ Another critical problem observed in commercial LLM deployments is the model's tendency to provide incorrect or hallucinated answers, especially when faced with logically inconsistent, ambiguous, or absurd questions.
380
+ Key reasons to evaluate this aspect include:
381
+ - **Hallucination Detection:** Preventing models from generating confident-sounding but entirely incorrect answers.
382
+ - **Logical Consistency:** Identifying and correctly responding (or explicitly refusing to respond) to internally inconsistent or logically flawed questions.
383
+ - **Protecting Model Reputation:** Ensuring the model avoids generating absurd or nonsensical answers, which significantly reduces user trust and solution credibility.
384
+ ---
385
  ### <span style='text-decoration: #FDA428 wavy underline;'>**Dataset Information**</span>
386
+ All samples were written by human. This benchmark dataset is divided clearly into two subsets corresponding to each testing area:
387
+ #### 1. **Implicatures and Phraseological Compounds Dataset**
388
+ - **Language:** Polish
389
+ - **Size:** 200 carefully selected examples
390
+ - **Structure of Each Example:**
391
+ - **Main Text:** Contains sarcasm, implicatures, and/or idiomatic phrases.
392
+ - **Reference Sentiment:** Annotated sentiment label (*positive*, *neutral*, *negative*).
393
+ - **Reference Phraseological Compounds:** Explicit list of phraseological expressions in the text.
394
+ - **Reference Explanation:** Clear explanation of the author's intended meaning.
395
+ #### 2. **Tricky Questions Dataset**
396
+ - **Language:** Polish
397
+ - **Size:** 178 examples (to be specified)
398
+ - **Types of Included Questions:**
399
+ - Logical riddles and puzzles.
400
+ - Questions based on semantic ambiguity (e.g., "How much sugar is needed to have a sweet voice?").
401
+ - Logically flawed questions (e.g., non-existent events or dates: "In what year did Poland witness a battle between Vatican and South Africa?").
402
+ - Absurd or humorous questions ("How can I join a snail chess club?").
403
+ ---
404
  ### <span style='text-decoration: #FDA428 wavy underline;'>**Evaluation Procedure**</span>
405
+ The evaluation procedure also consists of two clearly distinguished approaches:
406
+ #### 1. **Implicatures and Phraseological Compounds Evaluation**
407
+ ##### **Evaluated Model**
408
+ - For each text in the dataset, the evaluated model was explicitly required to list the following in three clearly separated points:
409
+ 1. **Sentiment** (*positive* or *negative* only).
410
+ 2. **The underlying intentions of the author**.
411
+ 3. **All phraseological compounds present in the text, along with their meanings in the given context**.
412
+ - **Prompt Structure**:
413
+ - Written entirely in Polish, without a system prompt.
414
+ - Contains three main elements (clearly separated by headers in capital letters and triple quotes):
415
+ 1. Information defining the evaluated model’s role as a careful linguist with extensive experience.
416
+ 2. Explicit instructions about the three tasks to be performed.
417
+ 3. Two diverse human-labeled examples:
418
+ - Example inputs are presented in the **User Prompt**.
419
+ - Corresponding example responses are presented separately in the **Assistant Prompt**.
420
+ - One target example (text) per evaluation follows after these examples.
421
+ - **Selection of Examples**:
422
+ - The two examples provided in the prompt were chosen due to diversity:
423
+ - One with negative sentiment and multiple phraseological compounds.
424
+ - One with positive sentiment and no phraseological compounds.
425
+ ##### **Judge Metamodel**
426
+ - Prompt structure similar to the evaluated model, but explicitly defines a distinct role ("reliable assistant") focused exclusively on evaluation.
427
+ - The judge metamodel’s prompt includes:
428
+ - Several diverse examples (with both positive and neutral sentiment references), each clearly separated into **User Prompt** (containing evaluated model responses and references) and **Assistant Prompt** (containing example evaluations by humans).
429
+ - Returns three separate evaluations in JSON format, clearly assessing:
430
+ 1. **Understanding of the Text** (`OCENA`) – a comparison of the evaluated model’s explanations to reference explanations.
431
+ 2. **Sentiment Analysis** (`WYDŹWIĘK`) – an optional evaluation performed only for samples explicitly labeled with "positive" or "negative" sentiment. Neutral samples were deliberately ignored to avoid ambiguity.
432
+ 3. **Phraseological Compounds** (`ZWIĄZKI`) – carefully evaluated with a penalization system to avoid "phrase spamming," deducting points for each non-reference or incorrect phrase until a minimum score of zero.
433
+ - **Example scoring output**:
434
  ```json
435
  {"WYDŹWIĘK": "5"}
436
  {"OCENA": "4"}
437
  {"ZWIĄZKI": "3"}
438
  ```
439
+ #### 2. **Tricky Questions Evaluation**
440
+ ##### **Evaluated Model**
441
+ - Receives only the tricky question itself as input, with **no system prompt** and **no additional instructions**.
442
+ ##### **Judge Metamodel**
443
+ - Uses GPT-4o with structured JSON outputs.
444
+ - Prompt structure explicitly includes **3 diverse examples** of tricky questions along with reference and evaluated-model responses, without dividing them into separate user and assistant prompts.
445
+ - Structured JSON evaluation includes:
446
+ - `"think"` field: detailed comparison of evaluated model’s answer to the reference, clearly explaining reasoning behind scoring.
447
+ - `"mark"` field: integer from 0 to 5 indicating performance (high scores correspond to accurate detection of logical flaws, ambiguity or absurdity, and appropriate refusal to hallucinate answers).
448
+ - Example scoring output:
449
+ ```json
450
+ {
451
+ "think": "Detailed reasoning comparing evaluated model's response to reference answer, noting if the evaluated model correctly identified logical inconsistency and avoided hallucination.",
452
+ "mark": 4
453
+ }
454
+ ```
455
+ - The addition of the `"think"` field significantly simplifies the analysis of the judge model's evaluations, explicitly clarifying the reasoning behind each awarded score.
456
  """, unsafe_allow_html=True)
457
 
458
 
 
462
  st.markdown("""
463
  ### Authors:
464
  - [Jan Sowa](https://www.linkedin.com/in/janpiotrsowa) - leadership, writing texts, benchmark code
465
+ - [Natalia Nadolna](https://www.linkedin.com/in/natalia-nadolna) - benchmark code, dataset cleaning & analysis
466
+ - [Anna Zielińska](https://www.linkedin.com/in/zieli%C5%84ska-anna/) - benchmark code, dataset cleaning & analysis
467
  - [Agnieszka Kosiak](https://www.linkedin.com/in/agn-kosiak/) - writing texts
468
  - [Magdalena Krawczyk](https://www.linkedin.com/in/magdalena-krawczyk-7810942ab/) - writing texts, labeling
469
  - [Marta Matylda Kania](https://www.linkedin.com/in/martamatyldakania/) - prompt engineering
 
472
  - [Szymon Baczyński](https://www.linkedin.com/in/szymon-baczynski/) - front-end / streamlit assistant
473
  - [Artur Słomowski](https://www.linkedin.com/in/arturslomowski/) - front-end / streamlit assistant
474
  - [Maria Filipkowska](https://www.linkedin.com/in/maria-filipkowska/) - writing text, linguistic support
475
+ - [Magda Król](https://www.linkedin.com/in/magda-król/) - writing text
476
+ - [Artur Gogol](https://www.linkedin.com/in/arturgogol) - writing text
477
  """)
478
 
479
  st.divider()
480
 
481
+ # Run the app with `streamlit run your_script.py`