Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code:   DatasetGenerationCastError
Exception:    DatasetGenerationCastError
Message:      An error occurred while generating the dataset

All the data files must have the same columns, but at some point there are 1 new columns ({'reference_answer'})

This happened while the csv dataset builder was generating data using

hf://datasets/fareedmughal/frontier-models-urdu-evaluation/csharp_30_questions_with_references.csv (at revision 848c084d416e55912f862cb773d3618095ad3d0b), ['hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/csharp_30_questions.csv', 'hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/csharp_30_questions_with_references.csv', 'hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/csharp_90_audited.csv', 'hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/csharp_90_raw_responses.csv', 'hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/scored_results (1).csv']

Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback:    Traceback (most recent call last):
                File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1848, in _prepare_split_single
                  writer.write_table(table)
                  ~~~~~~~~~~~~~~~~~~^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/arrow_writer.py", line 784, in write_table
                  self._write_table(pa_table, writer_batch_size=writer_batch_size)
                  ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/arrow_writer.py", line 795, in _write_table
                  pa_table = table_cast(pa_table, self._schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2378, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2306, in cast_table_to_schema
                  raise CastError(
                  ...<3 lines>...
                  )
              datasets.table.CastError: Couldn't cast
              question_id: string
              category: string
              concept: string
              english: string
              roman_urdu: string
              informal: string
              reference_answer: string
              -- schema metadata --
              pandas: '{"index_columns": [{"kind": "range", "name": null, "start": 0, "' + 1112
              to
              {'question_id': Value('string'), 'category': Value('string'), 'concept': Value('string'), 'english': Value('string'), 'roman_urdu': Value('string'), 'informal': Value('string')}
              because column names don't match
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1369, in compute_config_parquet_and_info_response
                  parquet_operations, partial, estimated_dataset_info = stream_convert_to_parquet(
                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~^
                      builder, max_dataset_size_bytes=max_dataset_size_bytes
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  )
                  ^
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 948, in stream_convert_to_parquet
                  builder._prepare_split(split_generator=splits_generators[split], file_format="parquet")
                  ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1694, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~^
                      gen_kwargs=gen_kwargs, job_id=job_id, **_prepare_split_args
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  ):
                  ^
                File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1850, in _prepare_split_single
                  raise DatasetGenerationCastError.from_cast_error(
                  ...<4 lines>...
                  )
              datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
              
              All the data files must have the same columns, but at some point there are 1 new columns ({'reference_answer'})
              
              This happened while the csv dataset builder was generating data using
              
              hf://datasets/fareedmughal/frontier-models-urdu-evaluation/csharp_30_questions_with_references.csv (at revision 848c084d416e55912f862cb773d3618095ad3d0b), ['hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/csharp_30_questions.csv', 'hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/csharp_30_questions_with_references.csv', 'hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/csharp_90_audited.csv', 'hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/csharp_90_raw_responses.csv', 'hf://datasets/fareedmughal/frontier-models-urdu-evaluation@848c084d416e55912f862cb773d3618095ad3d0b/scored_results (1).csv']
              
              Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

question_id
string
category
string
concept
string
english
string
roman_urdu
string
informal
string
Q001
C# Basics
FirstOrDefaultAsync
What does FirstOrDefaultAsync return when no matching record exists?
Matching record na mile to FirstOrDefaultAsync kya return karta hai?
bhai FirstOrDefaultAsync ko record na mile to kya return hoga?
Q002
C# Basics
NullReferenceException
What is a NullReferenceException in C#?
C# mein NullReferenceException kya hoti hai?
bhai NullReferenceException kab aati hai?
Q003
Arrays
Array Length
How do you get the number of elements in a C# array?
C# array mein elements ki tadaad kaise maloom karte hain?
bhai array mein total elements kaise count karun?
Q004
Collections
Stack Pop
What does Stack<T>.Pop() do in C#?
C# mein Stack<T>.Pop() kya karta hai?
bhai stack ka Pop call karun to hota kya hai?
Q005
ASP.NET Core
HTTP 404
When should an ASP.NET Core API return HTTP 404?
ASP.NET Core API ko HTTP 404 kab return karna chahiye?
bhai API mein 404 status code kab dena chahiye?
Q006
C# Basics
Value and Reference Types
What is the difference between value types and reference types in C#?
C# mein value types aur reference types mein kya farq hai?
bhai value type aur reference type ka scene kya hai?
Q007
C# Basics
Nullable Types
How can an integer variable hold null in C#?
C# mein integer variable ko null kaise assign kar sakte hain?
bhai int variable mein null rakhna ho to kaise karun?
Q008
C# Basics
String Equality
How can you compare two strings for equality in C#?
C# mein do strings ko equal kaise check karte hain?
bhai do strings same hain ya nahi kaise check karun?
Q009
Arrays
Array Index
What happens if you access an invalid array index in C#?
C# mein invalid array index access karne par kya hota hai?
bhai array ka wrong index access karun to kya hoga?
Q010
Arrays
Array vs List
What is one important difference between an array and a List<T> in C#?
C# mein array aur List<T> ka ek important farq kya hai?
bhai array aur List mein main difference kya hai?
Q011
Collections
Dictionary Lookup
How can you safely check whether a Dictionary contains a key in C#?
C# mein Dictionary ke andar key safely kaise check karte hain?
bhai dictionary mein key exist karti hai ya nahi kaise check karun?
Q012
Collections
HashSet
What is the main purpose of HashSet<T> in C#?
C# mein HashSet<T> ka main purpose kya hai?
bhai HashSet kis kaam aata hai?
Q013
OOP
Encapsulation
What is encapsulation in object-oriented programming?
Object-oriented programming mein encapsulation kya hoti hai?
bhai OOP mein encapsulation ka kya scene hai?
Q014
OOP
Inheritance
What is inheritance in C#?
C# mein inheritance kya hoti hai?
bhai inheritance ka simple matlab kya hai?
Q015
OOP
Polymorphism
What does polymorphism mean in C#?
C# mein polymorphism ka kya matlab hai?
bhai polymorphism ko simple words mein samjhao?
Q016
OOP
Interface
What is an interface used for in C#?
C# mein interface kis liye use hota hai?
bhai interface kyun banate hain?
Q017
OOP
Abstract Class
What is the difference between an abstract class and an interface in C#?
C# mein abstract class aur interface mein kya farq hai?
bhai abstract class aur interface mein main difference kya hai?
Q018
Async C#
Async Await
What do async and await do in C#?
C# mein async aur await kya karte hain?
bhai async await ka actual kaam kya hai?
Q019
Async C#
Task
What does Task<T> represent in C#?
C# mein Task<T> kis cheez ko represent karta hai?
bhai Task<T> ka kya matlab hota hai?
Q020
LINQ
Where
What does the Where method do in LINQ?
LINQ mein Where method kya karta hai?
bhai LINQ ka Where kis kaam aata hai?
Q021
LINQ
FirstOrDefault
What is the difference between First() and FirstOrDefault() in LINQ?
LINQ mein First() aur FirstOrDefault() mein kya farq hai?
bhai First aur FirstOrDefault mein difference kya hai?
Q022
Entity Framework Core
DbContext
What is DbContext used for in Entity Framework Core?
Entity Framework Core mein DbContext kis liye use hota hai?
bhai DbContext ka kya kaam hai?
Q023
Entity Framework Core
SaveChangesAsync
What does SaveChangesAsync() do in Entity Framework Core?
Entity Framework Core mein SaveChangesAsync() kya karta hai?
bhai SaveChangesAsync call karne se kya hota hai?
Q024
Entity Framework Core
Tracking
What is change tracking in Entity Framework Core?
Entity Framework Core mein change tracking kya hoti hai?
bhai EF Core ko kaise pata chalta hai entity change hui hai?
Q025
ASP.NET Core
Dependency Injection
What is dependency injection in ASP.NET Core?
ASP.NET Core mein dependency injection kya hoti hai?
bhai dependency injection ka simple matlab kya hai?
Q026
ASP.NET Core
Middleware
What is middleware in ASP.NET Core?
ASP.NET Core mein middleware kya hota hai?
bhai middleware request ke sath kya karta hai?
Q027
ASP.NET Core
Routing
What is routing in ASP.NET Core?
ASP.NET Core mein routing kya hoti hai?
bhai routing decide kaise karti hai ke request kahan jayegi?
Q028
ASP.NET Core
HTTP 401 vs 403
What is the difference between HTTP 401 and HTTP 403?
HTTP 401 aur HTTP 403 mein kya farq hai?
bhai 401 aur 403 status codes mein difference kya hai?
Q029
ASP.NET Core
DTO
Why might an ASP.NET Core API use a DTO instead of exposing an entity directly?
ASP.NET Core API mein entity directly dene ke bajaye DTO kyun use karte hain?
bhai API mein entity ki jagah DTO kyun bhejte hain?
Q030
Testing
Unit Testing
What is the purpose of a unit test in a C# application?
C# application mein unit test ka purpose kya hai?
bhai unit test kyun likhte hain?
Q001
C# Basics
FirstOrDefaultAsync
What does FirstOrDefaultAsync return when no matching record exists?
Matching record na mile to FirstOrDefaultAsync kya return karta hai?
bhai FirstOrDefaultAsync ko record na mile to kya return hoga?
Q002
C# Basics
NullReferenceException
What is a NullReferenceException in C#?
C# mein NullReferenceException kya hoti hai?
bhai NullReferenceException kab aati hai?
Q003
Arrays
Array Length
How do you get the number of elements in a C# array?
C# array mein elements ki tadaad kaise maloom karte hain?
bhai array mein total elements kaise count karun?
Q004
Collections
Stack Pop
What does Stack<T>.Pop() do in C#?
C# mein Stack<T>.Pop() kya karta hai?
bhai stack ka Pop call karun to hota kya hai?
Q005
ASP.NET Core
HTTP 404
When should an ASP.NET Core API return HTTP 404?
ASP.NET Core API ko HTTP 404 kab return karna chahiye?
bhai API mein 404 status code kab dena chahiye?
Q006
C# Basics
Value and Reference Types
What is the difference between value types and reference types in C#?
C# mein value types aur reference types mein kya farq hai?
bhai value type aur reference type ka scene kya hai?
Q007
C# Basics
Nullable Types
How can an integer variable hold null in C#?
C# mein integer variable ko null kaise assign kar sakte hain?
bhai int variable mein null rakhna ho to kaise karun?
Q008
C# Basics
String Equality
How can you compare two strings for equality in C#?
C# mein do strings ko equal kaise check karte hain?
bhai do strings same hain ya nahi kaise check karun?
Q009
Arrays
Array Index
What happens if you access an invalid array index in C#?
C# mein invalid array index access karne par kya hota hai?
bhai array ka wrong index access karun to kya hoga?
Q010
Arrays
Array vs List
What is one important difference between an array and a List<T> in C#?
C# mein array aur List<T> ka ek important farq kya hai?
bhai array aur List mein main difference kya hai?
Q011
Collections
Dictionary Lookup
How can you safely check whether a Dictionary contains a key in C#?
C# mein Dictionary ke andar key safely kaise check karte hain?
bhai dictionary mein key exist karti hai ya nahi kaise check karun?
Q012
Collections
HashSet
What is the main purpose of HashSet<T> in C#?
C# mein HashSet<T> ka main purpose kya hai?
bhai HashSet kis kaam aata hai?
Q013
OOP
Encapsulation
What is encapsulation in object-oriented programming?
Object-oriented programming mein encapsulation kya hoti hai?
bhai OOP mein encapsulation ka kya scene hai?
Q014
OOP
Inheritance
What is inheritance in C#?
C# mein inheritance kya hoti hai?
bhai inheritance ka simple matlab kya hai?
Q015
OOP
Polymorphism
What does polymorphism mean in C#?
C# mein polymorphism ka kya matlab hai?
bhai polymorphism ko simple words mein samjhao?
Q016
OOP
Interface
What is an interface used for in C#?
C# mein interface kis liye use hota hai?
bhai interface kyun banate hain?
Q017
OOP
Abstract Class
What is the difference between an abstract class and an interface in C#?
C# mein abstract class aur interface mein kya farq hai?
bhai abstract class aur interface mein main difference kya hai?
Q018
Async C#
Async Await
What do async and await do in C#?
C# mein async aur await kya karte hain?
bhai async await ka actual kaam kya hai?
Q019
Async C#
Task
What does Task<T> represent in C#?
C# mein Task<T> kis cheez ko represent karta hai?
bhai Task<T> ka kya matlab hota hai?
Q020
LINQ
Where
What does the Where method do in LINQ?
LINQ mein Where method kya karta hai?
bhai LINQ ka Where kis kaam aata hai?
Q021
LINQ
FirstOrDefault
What is the difference between First() and FirstOrDefault() in LINQ?
LINQ mein First() aur FirstOrDefault() mein kya farq hai?
bhai First aur FirstOrDefault mein difference kya hai?
Q022
Entity Framework Core
DbContext
What is DbContext used for in Entity Framework Core?
Entity Framework Core mein DbContext kis liye use hota hai?
bhai DbContext ka kya kaam hai?
Q023
Entity Framework Core
SaveChangesAsync
What does SaveChangesAsync() do in Entity Framework Core?
Entity Framework Core mein SaveChangesAsync() kya karta hai?
bhai SaveChangesAsync call karne se kya hota hai?
Q024
Entity Framework Core
Tracking
What is change tracking in Entity Framework Core?
Entity Framework Core mein change tracking kya hoti hai?
bhai EF Core ko kaise pata chalta hai entity change hui hai?
Q025
ASP.NET Core
Dependency Injection
What is dependency injection in ASP.NET Core?
ASP.NET Core mein dependency injection kya hoti hai?
bhai dependency injection ka simple matlab kya hai?
Q026
ASP.NET Core
Middleware
What is middleware in ASP.NET Core?
ASP.NET Core mein middleware kya hota hai?
bhai middleware request ke sath kya karta hai?
Q027
ASP.NET Core
Routing
What is routing in ASP.NET Core?
ASP.NET Core mein routing kya hoti hai?
bhai routing decide kaise karti hai ke request kahan jayegi?
Q028
ASP.NET Core
HTTP 401 vs 403
What is the difference between HTTP 401 and HTTP 403?
HTTP 401 aur HTTP 403 mein kya farq hai?
bhai 401 aur 403 status codes mein difference kya hai?
Q029
ASP.NET Core
DTO
Why might an ASP.NET Core API use a DTO instead of exposing an entity directly?
ASP.NET Core API mein entity directly dene ke bajaye DTO kyun use karte hain?
bhai API mein entity ki jagah DTO kyun bhejte hain?
Q030
Testing
Unit Testing
What is the purpose of a unit test in a C# application?
C# application mein unit test ka purpose kya hai?
bhai unit test kyun likhte hain?
Q001
C# Basics
FirstOrDefaultAsync
null
null
null
Q001
C# Basics
FirstOrDefaultAsync
null
null
null
Q001
C# Basics
FirstOrDefaultAsync
null
null
null
Q002
C# Basics
NullReferenceException
null
null
null
Q002
C# Basics
NullReferenceException
null
null
null
Q002
C# Basics
NullReferenceException
null
null
null
Q003
Arrays
Array Length
null
null
null
Q003
Arrays
Array Length
null
null
null
Q003
Arrays
Array Length
null
null
null
Q004
Collections
Stack Pop
null
null
null
Q004
Collections
Stack Pop
null
null
null
Q004
Collections
Stack Pop
null
null
null
Q005
ASP.NET Core
HTTP 404
null
null
null
Q005
ASP.NET Core
HTTP 404
null
null
null
Q005
ASP.NET Core
HTTP 404
null
null
null
Q006
C# Basics
Value and Reference Types
null
null
null
Q006
C# Basics
Value and Reference Types
null
null
null
Q006
C# Basics
Value and Reference Types
null
null
null
Q007
C# Basics
Nullable Types
null
null
null
Q007
C# Basics
Nullable Types
null
null
null
Q007
C# Basics
Nullable Types
null
null
null
Q008
C# Basics
String Equality
null
null
null
Q008
C# Basics
String Equality
null
null
null
Q008
C# Basics
String Equality
null
null
null
Q009
Arrays
Array Index
null
null
null
Q009
Arrays
Array Index
null
null
null
Q009
Arrays
Array Index
null
null
null
Q010
Arrays
Array vs List
null
null
null
Q010
Arrays
Array vs List
null
null
null
Q010
Arrays
Array vs List
null
null
null
Q011
Collections
Dictionary Lookup
null
null
null
Q011
Collections
Dictionary Lookup
null
null
null
Q011
Collections
Dictionary Lookup
null
null
null
Q012
Collections
HashSet
null
null
null
Q012
Collections
HashSet
null
null
null
Q012
Collections
HashSet
null
null
null
Q013
OOP
Encapsulation
null
null
null
Q013
OOP
Encapsulation
null
null
null
Q013
OOP
Encapsulation
null
null
null
Q014
OOP
Inheritance
null
null
null
End of preview.

Systematic Evaluation of Cross-Register Brittleness: Colloquial-Induced Contextual Amnesia and the Subword Tokenization Penalty in Frontier Models

Target Model Evaluated: Qwen/Qwen3-4B (Open-weight, 4.02 Billion Parameters)
Execution Environment: Google Colab Cloud Infrastructure (NVIDIA Tesla T4 GPU, 16GB VRAM, CUDA 12.2)
Evaluation Methodology: 90 Multi-Register Deterministic Inference Executions (Greedy Decoding, Temperature=0.0)
Benchmark Artifacts: Curated 30-Concept C# Canonical Dataset, Raw Generation Logs, Multi-Metric Algorithmic Audits


Executive Summary

State-of-the-art frontier model evaluations assume that software engineering occurs in clean, formal, documentation-style English. In non-Western software engineering ecosystemsβ€”specifically across Pakistan and the broader South Asian diasporaβ€”technical collaboration is heavily conducted in Roman Urdu / Hinglish (a Latin-scripted transliteration of vernacular Indo-Aryan syntax heavily fused with English technical nomenclature).

Using Qwen/Qwen3-4B, this research demonstrates that introducing Latinized colloquial phrasing into technical prompts triggers catastrophic capability degradation across two orthogonal dimensions:

  1. Colloquial-Induced Contextual Amnesia (Programming Language Drift): When a technical prompt contains colloquial peer-to-peer markers (e.g., "bhai", "scene kya hai"), the model undergoes severe conditioning collapseβ€”abandoning the target programming language (C#) in 36.7% of code-generating queries and hallucinating implementations in Python, JavaScript, Java, and C++.
  2. The Subword Tokenization Penalty & Asymmetric Code-Switching: Subword Byte-Pair Encoding (BPE) tokenizers fail to allocate dedicated vocabulary indices for Romanized vernacular words. This induces an immediate 53.9% token generation bloat, driving an unacceptably high 20.0% mid-thought truncation rate within bounded generation windows, and causing an involuntary breakdown of communicative reciprocity wherein the model abandons the user's dialect to reply in English over 50% of the time.

1. Identified Blind Spot & Grounding in Lived Experience

1.1 The Epistemic Gap in Modern Benchmarking Suites

Standard language model evaluation suitesβ€”including HumanEval, MBPP, MultiPL-E, GSM8K, and SWE-benchβ€”operate on a shared foundational assumption: developer prompts are composed in grammatically pristine, formal, monolingual English. While recent efforts have expanded benchmarks to multilingual settings (e.g., evaluating code models on native scripts like Arabic or Devanagari), they maintain an artificial division between formal high-resource languages and standardized national orthographies.

This setup excludes the primary day-to-day written medium of over 400 million internet users across South Asia: Romanized code-switching.

1.2 Grounding in Lived Experience

As a practicing software engineer within the Pakistani software development ecosystem, day-to-day engineering workflows rarely occur in textbook English or formal Perso-Arabic Urdu script (اردو). Inside technical communication channelsβ€”ranging from GitHub pull request (PR) reviews, internal Slack channels, Microsoft Teams debugging huddles, to urgent WhatsApp architectural discussionsβ€”the de facto communication standard is Roman Urdu:

"bhai FirstOrDefaultAsync ko record na mile to kya return hoga? Null reference to throw nahi karega?"
(Rather than: "What does FirstOrDefaultAsync return when no matching record exists in EF Core? Will it throw a NullReferenceException?")

This dialect is not an uneducated simplification; it is an optimized, high-density socio-technical register. The vocabulary preserves formal English identifiers for frameworks, type systems, and API signatures (e.g., FirstOrDefaultAsync, NullReferenceException, DbContext, IQueryable<T>), while the relational and logical reasoning connective tissue is mediated through native Indo-Aryan grammatical syntax ("kya scene hai", "kaise count karun", "kab aati hai").

1.3 The Core Capability Gaps

Through iterative, manual, and automated exploration, I isolated two interrelated failure modes in frontier reasoning models:

Capability Gap A: Colloquial-Induced Contextual Amnesia (Cross-Language Code Drift)

Frontier code models treat informal registers not merely as stylistic shifts, but as domain degradation. In formal English prompts, implicit contextual associations remain tightly bound (e.g., querying FirstOrDefaultAsync or array operations correctly routes to C#/.NET).

However, the moment colloquial peer-level framing is introduced (such as the ubiquitous regional marker "bhai" or "yaar"), the model's technical conditioning collapses. The model disassociates from the enterprise C# ecosystem and defaults to general-purpose scripting languages (such as JavaScript or Python). This reveals an implicit bias in alignment: models associate conversational, non-Western framing with introductory web development or scripting, stripping enterprise semantics from the query.

Capability Gap B: The Subword Tokenization Penalty and Asymmetric Code-Switching

Tokenizers such as Byte-Pair Encoding (BPE) and WordPiece are trained on massive Western corpora dominated by English web scrapes and standard Unicode scripts. Because Roman Urdu is an unstandardized, phonetic transcription system, common grammatical words are fragmented into character-level n-grams and disjoint byte sequences.

This causes two severe cascading failures:

  1. Token Bloat & Truncation: To express the exact same technical explanation, the model must emit 50% to 60% more tokens in Roman Urdu than in English, exhausting its maximum output context window and truncating code blocks before critical termination tokens are emitted.
  2. Asymmetric Linguistic Collapse: Because generating subword-fragmented tokens incurs a high autoregressive entropy cost, the model frequently defaults to an unrequested register switchβ€”answering Roman Urdu inquiries in textbook English, breaking conversational symmetry.

2. Systematic Empirical Evaluation Methodology

2.1 Model Selection Criteria

To rigorously test this hypothesis, I selected Qwen/Qwen3-4B (hosted on Hugging Face).

  • Parameter Window Adherence: At 4.02 billion parameters, it sits directly within the required 0.6B to 6B parameter window.
  • Frontier Representation: The Qwen family represents state-of-the-art open-weight autoregressive architectures, exhibiting reasoning and code generation capabilities comparable to significantly larger legacy models.
  • Local Reproducibility: Its parameter scale allows local loading on a single commodity GPU (Google Colab free-tier NVIDIA Tesla T4 GPU, 16GB VRAM) under 16-bit half-precision (torch.float16) without requiring lossy 4-bit quantization, eliminating quantization noise as a confounding variable.

2.2 Dataset Architecture

I developed a curated benchmark suite comprising 30 fundamental C# and .NET architectural concepts spanning 6 foundational domains of modern enterprise software engineering:

  1. Core C# Runtime Fundamentals: Value vs. Reference types, Nullable value types (int?), String equality semantics (StringComparison), NullReferenceException.
  2. Data Structures & Collections: Array allocation and length mechanics, List<T> dynamic sizing, LIFO operations (Stack<T>.Pop()), Membership hashing (HashSet<T>), Key-value lookups (Dictionary<TKey, TValue>).
  3. Object-Oriented Programming (OOP): Encapsulation and access control, Single inheritance hierarchies, Dynamic polymorphism and virtual dispatch, Interface contracts, Abstract base classes.
  4. Asynchronous Architecture: The async/await state machine, Task-based Asynchronous Pattern (Task<T>).
  5. Entity Framework Core (ORM): Asynchronous query execution (FirstOrDefaultAsync), Atomic database persistence (SaveChangesAsync), Snapshot and change tracking mechanics, DbContext lifetime scope.
  6. ASP.NET Core Web APIs: Middleware request pipelines, Declarative routing engines, Authentication vs. Authorization status codes (HTTP 401 vs 403), Resource missing handling (HTTP 404), Data Transfer Objects (DTOs), Unit testing isolation.

To strictly isolate the impact of linguistic register, each of the 30 concepts was authored in three parallel, semantic-preserving registers, producing 90 structured evaluation prompts:

  • Register 1: Formal English (Baseline): Standard textbook documentation style (e.g., "What does FirstOrDefaultAsync return when no matching record exists?").

  • Register 2: Neutral Roman Urdu: Orthographically correct, Latin-scripted transliteration without slang (e.g., "Matching record na mile to FirstOrDefaultAsync kya return karta hai?").

  • Register 3: Informal Roman Urdu: Authentic developer vernacular featuring conversational peer markers (e.g., "bhai FirstOrDefaultAsync ko record na mile to kya return hoga?").

    2.3 Inference & Audit Protocol

Inference was executed deterministically via Hugging Face transformers using greedy decoding (do_sample=False, pad_token_id=eos_token_id, max_new_tokens=550) to ensure absolute reproducibility. Every generation was flushed dynamically to persistent Google Drive checkpoints to prevent execution loss.

A specialized multi-metric audit script was built to classify every response along four orthogonal axes:

  1. Code Block Language Detection: Parsing Markdown backticks to verify whether the code was annotated and written in C# or drifted into alternative languages (python, javascript, java, cpp).
  2. Response Language Mirroring: Quantifying lexical density of Indo-Aryan functional particles (hai, hain, mein, karta, kese, chahiye) to determine whether the model sustained Roman Urdu or collapsed into English.
  3. Subword Token Generation Bloat: Tracking exact generated sequence length ($L_{gen} = L_{total} - L_{prompt}$).
  4. Premature Context Exhaustion (Truncation): Identifying responses terminating at the token ceiling ($\ge 545$ tokens) or ending abruptly mid-sentence/mid-code block.

2.4 Quantitative Empirical Findings

The empirical evaluation of all 90 queries yielded stark quantitative divergences across linguistic registers.

Table 1: Code Language Drift & Linguistic Conditioning Audit

Language Register Evaluated Queries Valid C# Code Generated No Code Block Output Drifted to Other Languages Target Language Drift Rate (%)
Formal English 30 16 13 0 0.0%
Neutral Roman Urdu 30 15 14 1 (Python) 3.3%
Informal Roman Urdu 30 7 12 11 (6 Py, 2 JS, 2 Java, 1 C++) 36.7%

Table 2: Computational Tokenization Penalty & Linguistic Symmetry

Language Register Average Generated Tokens Token Bloat vs Baseline (%) Truncation Rate (Cut-off mid-thought) Asymmetric Collapse to English
Formal English 228.5 Baseline (0.0%) 0.0% (0/30) N/A
Informal Roman Urdu 332.8 +45.6% 16.7% (5/30) 56.7% (17/30)
Neutral Roman Urdu 351.7 +53.9% 20.0% (6/30) 46.7% (14/30)

2.5 In-Depth Failure Analysis & Case Studies

Failure Mode 1: Colloquial-Induced Programming Language Drift

When queries were framed in formal English or neutral Roman Urdu, Qwen/Qwen3-4B demonstrated strong contextual awareness, emitting C# syntax even when the explicit keyword "C#" was absent from the immediate sentence.

However, under informal framing ("bhai..."), the model's semantic conditioning suffered catastrophic interference. In 36.7% of code-generating prompts, the model hallucinated syntax from completely unrelated languages:

  • Case Study A (Concept Q003 - Array Length):

    • Prompt: "bhai array mein total kitne elements hain wo kese check karun?"
    • Expected Output: C# .Length property access (int count = numbers.Length;).
    • Actual Model Generation: The model emitted JavaScript code:
      let arr = [1, 2, 3, 4, 5];
      console.log(arr.length); // Output: 5
      
      Mechanics: The colloquial token sequence "bhai ... kese check karun" overpowered the enterprise C# context, causing the attention heads to route into high-frequency, beginner-level JavaScript web-development clusters.
  • Case Study B (Concept Q020 - LINQ Filtering):

    • Prompt: "bhai LINQ ka Where kis kaam aata hai?"
    • Actual Model Generation: The model explained LINQ conceptually but supplied a Python list comprehension example ([x for x in list if condition]) alongside a Python code snippet, completely breaking framework alignment.

Failure Mode 2: The Subword Tokenization Bloat & Truncation Penalty

Due to the absence of dedicated vocabulary tokens for Roman Urdu prefixes and suffixes, token sequences exploded.

  • In Formal English, an exhaustive explanation of Stack<T>.Pop() consumed 184 tokens.
  • In Roman Urdu, the identical semantic explanation consumed 412 tokensβ€”a 123.9% expansion.

Within the 550-token window, 20.0% of neutral Roman Urdu responses and 16.7% of informal responses truncated mid-sentence or mid-expression, frequently leaving unclosed classes, unhandled exceptions, and broken method signatures. Conversely, the English truncation rate was 0.0%.

Failure Mode 3: Asymmetric Linguistic Mirroring

In 56.7% of informal queries and 46.7% of neutral queries, the model exhibited linguistic asymmetry: it ingested the Roman Urdu prompt, correctly processed the conceptual request, but formulated the entire output in formal documentation English. The model failed to maintain stylistic and cultural parity with the user, reflecting an alignment regime that treats non-English prompts as translation triggers rather than valid interaction media.


3. Proposed Path Forward

To permanently close this gap without compromising the model's general reasoning capabilities, I propose a three-tiered architectural, curation, and alignment roadmap.

              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ 3-Tiered Mitigation Architecture  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β–Ό                             β–Ό                                β–Ό

[Tier 1: Tokenizer Expansion] [Tier 2: Adversarial SFT] [Tier 3: Symmetry DPO] β€’ 10,000 Romanized subwords β€’ Colloquial enterprise pairs β€’ Dispreference penalties β€’ Zero-entropy byte encoding β€’ Invariant language loss β€’ Linguistic parity reward

3.1 Tier 1: Tokenizer Vocabulary Allocation for Romanized Vernaculars (Pre-training / Adaptation)

The 53.9% tokenization bloat is a direct artifact of vocabulary allocation bias in BPE tokenizers.

  • Strategy: Construct a corpus of 500 million tokens of South Asian developer interactions (scraped from public GitHub pull request discussions, regional Stack Overflow interactions, local developer forums, and open-source Slack/Discord communities).
  • Execution: Run a targeted Byte-Pair Encoding merge step to identify the top 10,000 most frequent Roman Urdu/Hinglish n-grams (e.g., karna, karta, hoga, kese, chahiye, raha, hain, samjh).
  • Architectural Adjustment: Expand the model's embedding matrix $W_e \in \mathbb{R}^{V \times d}$ to $W_e' \in \mathbb{R}^{(V + 10000) \times d}$, initializing the new embeddings via weighted averages of their constituent subword embeddings.
  • Expected Outcome: Sequence length compression of ~40% for Romanized technical prompts, directly eliminating the tokenization bloat penalty and lowering the truncation rate to parity with English.

3.2 Tier 2: Colloquial Adversarial Context Tuning (Supervised Fine-Tuning - SFT)

To eliminate Programming Language Drift, the model must be trained to decouple linguistic register from technical domain.

  • Dataset Curation Strategy: Synthesize an adversarial instruction dataset of 25,000 technical programming pairs. Each sample pairs an informal, colloquial prompt in Roman Urdu, Hinglish, or informal vernacular with an enterprise-grade, technically rigorous code implementation strictly anchored in the queried language.
  • Invariant Language Loss Formulation: Introduce an auxiliary classification loss during instruction fine-tuning that penalizes cross-language drift. If a prompt's underlying domain is classified as $D_{target}$ (e.g., C#/.NET), any generation containing syntax exclusive to $D_{alt}$ (e.g., Python def, JavaScript console.log) incurs an exponential gradient penalty: Ltotal=LNLL+Ξ»βˆ‘t=1TI(yt∈Valt)\mathcal{L}_{total} = \mathcal{L}_{NLL} + \lambda \sum_{t=1}^{T} \mathbb{I}(y_t \in \mathcal{V}_{alt})
  • Expected Outcome: The model learns that conversational colloquialisms ("bhai", "yaar") denote interpersonal solidarity, not reduced technical complexity or authorization to switch programming languages.

3.3 Tier 3: Dialectal Symmetry Optimization via Direct Preference Optimization (DPO)

To resolve Asymmetric Code-Switching, we propose aligning the model's generation policy using Direct Preference Optimization (DPO).

  • Preference Pair Design ($y_w \succ y_l$):
    • Prompt ($x$): Informal Roman Urdu technical query (e.g., "bhai DbContext ka lifecycle ASP.NET Core mein kaise handle hota hai?").
    • Winning Response ($y_w$): Rigorous technical explanation written in fluent Roman Urdu, incorporating exact C# code snippets with complete lifecycle scopes (AddScoped, AddDbContext).
    • Losing Response ($y_l$): A response that answers correctly in code, but breaks linguistic symmetry by replying entirely in formal English, or a response that switches to Python/SQL.
  • Optimization Objective: LDPO(πθ;Ο€ref)=βˆ’E(x,yw,yl)[log⁑σ(Ξ²log⁑πθ(yw∣x)Ο€ref(yw∣x)βˆ’Ξ²log⁑πθ(yl∣x)Ο€ref(yl∣x))]\mathcal{L}_{DPO}(\pi_\theta; \pi_{ref}) = -\mathbb{E}_{(x, y_w, y_l)} \left[ \log \sigma \left( \beta \log \frac{\pi_\theta(y_w\vert{}x)}{\pi_{ref}(y_w\vert{}x)} - \beta \log \frac{\pi_\theta(y_l\vert{}x)}{\pi_{ref}(y_l\vert{}x)} \right) \right]
  • Expected Outcome: By penalizing register collapse, the model's policy $\pi_\theta$ learns to maintain stylistic and dialectal symmetry across all interactions, respecting the user's native linguistic register while maintaining flawless technical execution.

4. Repository Artifacts & Replication Guide

This Hugging Face repository contains all artifacts necessary to reproduce every finding reported in this study:

4.1 Artifact Manifest

  • csharp_30_questions_benchmark.csv: The complete curated benchmark dataset containing all 30 canonical C# concepts authored across three parallel linguistic registers (Formal English, Neutral Roman Urdu, Informal Roman Urdu) alongside human-authored gold reference answers.
  • csharp_90_results.csv: The raw model generations produced by Qwen/Qwen3-4B during deterministic execution, containing raw text, exact token metrics, and execution metadata.
  • csharp_90_deep_audit.csv: The algorithmic audit output evaluating code block language integrity, subword token bloat ratios, and linguistic mirroring classifications.
  • evaluation_notebook.ipynb: A standalone, self-contained Google Colab execution notebook containing model loading, greedy generation loops, Drive checkpointing logic, and auditing pipelines.

4.2 Reproduction Pipeline

To reproduce these findings on a free-tier Google Colab instance:

  1. Clone this repository or download roman_urdu (3).ipynb.
  2. Open the notebook in Google Colab and set the runtime environment to T4 GPU (Runtime > Change runtime type > T4 GPU).
  3. Execute the cells sequentially. The notebook will pull Qwen/Qwen3-4B directly from Hugging Face, execute the deterministic inference loop across all 90 prompt instances, write raw responses directly to persistent storage, and execute the automated audit script to reproduce Tables 1 and 2 verbatim.
Downloads last month
42