Invisible Prompts
How Naming and Comments Improve LLM Performance
When working with large language models (LLMs), we usually focus on designing the perfect prompt. But prompts aren't always explicit. In many modern frameworks like OpenAI's tools, LangChain, or Rig (which I use in Rust), LLMs also use code context, including variable names, comments, and data structures, to interpret and generate responses.
Here's a real-world example from an extractor I was developing. Initially, I used the following code:
pub struct Book { // title of name of the book otherwise null title:
Option<String>,
// writer or author of the book otherwise null #
[serde(rename = "author")]
author: Option<String>,
// string containing key ideas of the book otherwise null
key_ideas: Option<String>,
// string containg a list of questions which we could answer based on the contents of this book; otherwise, null questions:
Option<String>,
// string contains a list thematic of which is not directly answered in this book but could be used as a theoretical background for broader analytics
theories: Option<String>,
}The logic was sound, but the model's extraction accuracy was inconsistent. Instead of changing the model or adding explicit instructions, I simply revised the variable names and added meaningful comments without altering any logic:
#[derive(Debug, Deserialize, JsonSchema, Serialize)]
pub struct Book {
/// **TITLE EXTRACTION**
/// Extract the main title in Arabic or English
/// Look for: العنوان الرئيسي or main title
/// Examples: "تشريح الدولة المصرية", "Egypt's Political Economy", "الاقتصاد السياسي للثورة"
/// If bilingual, capture both: "Arabic Title / English Title"
/// Return None if no clear title found
#[serde(rename = "title")]
title: Option<String>,
/// **AUTHOR EXTRACTION**
/// Extract author names in original script
/// Common patterns: "تأليف", "المؤلف", "By", "د.", "أ.د."
/// Include academic titles: "د. سامر سليمان", "أ.د. جلال أمين"
/// Multiple authors: "Author1; Author2"
/// Return None if no author found
#[serde(rename = "authors")]
authors: Option<String>,
/// **SUBTITLE EXTRACTION**
/// Extract subtitle clarifying scope or period
/// Examples: "من عبد الناصر إلى السيسي", "دراسة في الاقتصاد غير الرسمي"
/// Return None if no subtitle
#[serde(rename = "subtitle")]
subtitle: Option<String>,
/// **PUBLISHER & LOCATION**
/// Extract publisher and city
/// Common: "دار الشروق - القاهرة", "الهيئة المصرية العامة للكتاب"
/// Include year if present: "Publisher, Cairo, 2023"
/// Return None if not found
#[serde(rename = "publisher")]
publisher: Option<String>,
/// **MAIN THESIS (Arabic/English)**
/// Extract central argument about Egyptian society/economy
/// Look in: مقدمة, تمهيد, الفصل الأول, Introduction
/// Example: "يرى الكاتب أن الجيش المصري تحول إلى فاعل اقتصادي رئيسي"
/// Translate if needed: "The military has become a primary economic actor"
/// 2-4 sentences maximum
/// Return None if unclear
#[serde(rename = "main_thesis")]
main_thesis: Option<String>,
/// **INTERNATIONAL RELATIONS FOCUS**
/// Identify foreign relations discussed
/// Common: "IMF agreements", "Gulf aid", "US military aid", "EU trade"
/// Include regional: "Saudi relations", "Ethiopian dam dispute", "Gaza border"
/// Return None if domestic focus only
#[serde(rename = "international_relations")]
international_relations: Option<String>,
/// **THEORETICAL FRAMEWORK**
/// Identify analytical approach
/// Examples: "Rentier state theory", "Authoritarian bargain", "Neoliberalism", "Dependency theory"
/// Can be Egyptian-specific: "Nasser's Arab socialism"
/// Return None if atheoretical
#[serde(rename = "theoretical_framework")]
theoretical_framework: Option<String>,
/// **REGIONAL COMPARISONS**
/// Note comparisons to other Arab/MENA countries
/// Examples: "Compares to Tunisia's transition", "Contrasts with Gulf monarchies", "Similar to Jordan's economy"
/// Return None if Egypt-only focus
#[serde(rename = "regional_comparisons")]
regional_comparisons: Option<String>,
//
// I remove some of the variables to make this code snap shorter
//
/// **EXTRACTION CONFIDENCE**
/// Float 0.0-1.0 for extraction quality
/// Consider: Arabic OCR quality, completeness, context understanding
/// Lower score if many fields empty or uncertain
#[serde(rename = "confidence_score")]
confidence_score: f32,
}Surprisingly, the extractor’s performance improved significantly. This shows that descriptive variable names and clear comments can serve as implicit prompts, helping the model better understand intent and context.
Key takeaway: Your code is part of the prompt. Small changes in structure and naming can dramatically improve LLM results, even without altering the core logic or adding explicit prompts.
PS: What I did not try, but I would like to try, is this extra work on Arabic. If I include comments in Arabic, how will it affect performance?

