An intelligent LinkedIn post generator powered by few-shot learning and large language models. Create engaging, professional LinkedIn content tailored to your topic, length, and language preferences.
The LinkedIn Post Generator is an AI-powered application that generates high-quality LinkedIn posts using a few-shot prompting approach. By leveraging real LinkedIn post examples enriched with metadata, the system intelligently selects similar posts and uses them as context to generate new, engaging content through the Llama 3.3 model via Groq API.
This project demonstrates practical applications of:
- Few-shot learning for content generation
- Metadata-driven filtering for context-aware AI responses
- Modern LLM orchestration using LangChain
- Interactive web interfaces with Streamlit
- π― Topic-Based Generation: Select from predefined topics to generate relevant content
- π Customizable Length: Choose between short, medium, or long post formats
- π Multi-Language Support: Generate posts in different languages
- π§ Few-Shot Learning: Uses real LinkedIn post examples to guide AI generation
- π¨ Interactive UI: Clean, user-friendly Streamlit interface
- β‘ Fast Processing: Powered by Groq's high-performance API
- π Smart Filtering: Metadata-based example selection for better context
The application follows a sophisticated pipeline to generate contextually relevant LinkedIn posts:
- Raw LinkedIn posts are collected and stored
- Each post is enriched with metadata:
- Line count: Determines post length category
- Language: Identifies the language of the post
- Tags: Categorizes posts by topic/theme
- Enriched posts are processed and stored in a structured format
- Metadata enables efficient filtering and retrieval
When a user requests a new post:
- Load processed example posts from storage
- Filter examples by selected topic, length, and language
- Select up to 2 most similar examples
- Build a few-shot prompt with selected examples
- Send prompt to Llama 3.3 via Groq API
- Generate and display the new LinkedIn post
βββββββββββββββββββ
β Raw LinkedIn β
β Posts β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Metadata β
β Enrichment β
β (Line count, β
β Language, Tags)β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Processed β
β Dataset β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β User Input (UI) β
β Topic | Length | Language β
ββββββββββ¬βββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Filter & Selectβ
β Similar Posts β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Few-Shot β
β Prompt Builder β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Groq API β
β (Llama 3.3) β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Generated β
β LinkedIn Post β
βββββββββββββββββββ
| Technology | Purpose |
|---|---|
| Core programming language | |
| Web UI framework | |
| LLM orchestration & prompt management | |
| High-performance LLM API | |
| Llama 3.3 | Large language model |
| Pandas | Data processing & filtering |
Linkedin_post_generator/
β
βββ main.py # Streamlit entry point
βββ llm_helper.py # LLM API handler
βββ post_generator.py # Post creation logic
βββ preprocess.py # Data preprocessing
βββ few_shot.py # Few-shot prompt templates
βββ data/ # Raw and processed posts
βββ requirements.txt
βββ README.md
---
## βοΈ Installation & Setup
### Prerequisites
- Python 3.8 or higher
- pip package manager
- Groq API account ([Sign up here](https://groq.com))
### Step 1: Clone the Repository
```bash
git clone https://github.com/anujakhatri/linkedin-post-generator.git
cd linkedin-post-generator
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txt
β οΈ IMPORTANT: Never commit your API keys to GitHub!
Copy the example environment file:
cp .env.example .envOpen .env and add your API key:
GROQ_API_KEY=your_groq_api_key_here- Visit Groq Console
- Sign up or log in
- Navigate to API Keys section
- Generate a new API key
- Copy and paste it into your
.envfile
π‘ Tip: The
.envfile is already included in.gitignoreto prevent accidental commits.
streamlit run app/main.pyThe application will open in your default browser at http://localhost:8501
- Select a Topic: Choose from available categories (e.g., Technology, Marketing, Career)
- Choose Length: Pick short, medium, or long format
- Select Language: Choose your preferred language
- Generate: Click the generate button
- Review: View your AI-generated LinkedIn post
- Copy & Post: Copy the content to LinkedIn
- Topic: Artificial Intelligence
- Length: Medium
- Language: English
The key? Building systems that are:
β
Transparent
β
Accountable
β
Human-centered
#ArtificialIntelligence #TechInnovation #FutureOfWork
- User Authentication: Allow users to save favorite posts
- Custom Training: Enable users to upload their own post examples
- Multi-Model Support: Add support for GPT-4, Claude, and other LLMs
- Analytics Dashboard: Track generation metrics and popular topics
- Tone Customization: Add options for professional, casual, or inspirational tones
- Hashtag Suggestions: Auto-generate relevant hashtags
- Export Options: Download posts as PDF or share directly to LinkedIn
- A/B Testing: Compare multiple generated versions
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Please ensure your code follows the existing style and includes appropriate tests.
- Groq for providing high-performance LLM API
- LangChain for excellent LLM orchestration tools
- Streamlit for the intuitive web framework
- Meta AI for the Llama 3.3 model
β Star this repo if you find it helpful!
Made with β€οΈ by Anuja Khatri