Just published my first open-source Python package — llmclean If you've ever piped raw LLM output directly into json.loads() and watched it explode, this is for you. Three utilities, zero dependencies: • strip_fences — removes the ```json ``` wrappers LLMs love to add • enforce_json — extracts valid JSON even when the model returns True instead of true, trailing commas, unquoted keys, or buries the JSON in prose • trim_repetition — cuts the looping tail when a model repeats itself Every function fails gracefully — if cleaning fails, you get the original back. It never throws. use with : pip install llmclean GitHub: https://lnkd.in/gQt4auQ2 PyPI : https://lnkd.in/guNpmtnm Built this because I kept copy-pasting the same cleaning logic across projects. Figured someone else probably was too. #Python #OpenSource #LLM #AI #Dev
Python LLM Output Cleaner: llmclean Package Released
More Relevant Posts
-
𝗗𝗲𝗽𝗹𝗼𝘆 𝘆𝗼𝘂𝗿 𝗠𝗟 𝗠𝗼𝗱𝗲𝗹 𝘄𝗶𝘁𝗵 𝗙𝗮𝘀𝘁𝗔𝗣𝗜 Machine learning models are commonly deployed as web applications, but you may also consider alternative options. FastAPI is a Python framework that lets you easily develop web APIs based on industry standards like OpenAPI and the JSON schema. Machine learning engineers can utilize FastAPI to deploy their models as APIs, and develop robust services that are production-ready. Have you ever developed a machine learning API? You can check the links below for more information, and make sure to follow me for regular data science content. 𝗙𝗮𝘀𝘁𝗔𝗣𝗜 𝗼𝗳𝗳𝗶𝗰𝗶𝗮𝗹 𝘄𝗲𝗯𝘀𝗶𝘁𝗲: https://lnkd.in/djw9ME8j 𝗟𝗲𝗮𝗿𝗻 𝗠𝗟 𝘄𝗶𝘁𝗵 𝗣𝘆𝗖𝗮𝗿𝗲𝘁: https://lnkd.in/dyByK4F #datascience #python #machinelearning #deeplearning
To view or add a comment, sign in
-
-
Technical post: I've been posting some graphs on here, talking about functions and "equivalence". This was all started by working on porting an MLOPs framework from python 3.10 to 3.12, and all the "dependency hell" one has to go through. Then naturally the question arose "What are the boundaries of one project to another, in terms of functions being called etc.,?" This led me down the rabbit hole (not too deep) of what happens when I do something like python -m <module> <somescript>. Specifically, what is a "no op" module, and what kind of ops can we inject, thanks to python being an interpreted language. A few years ago I'd worked on something along similar lines called TracePath, which provided a decorator to do something similar (e.g. who called who, how long it took, etc.). So I merged these two ideas (avoid decorating every function, have an "inspector" module) and ran this on a simple pandas dataframe creation. The resulting function invocation graph is the image attached to this post. When I ran it across the whole workflow (create, load, transform data etc.,), the graph had ~9000 connections. The nice thing is I can specify which modules (e.g. only pandas, or pandas and numpy) should be added to the graph etc. What do you think is the next logical thing to do with something like this? What kind of graphs would well structured software produce? How about badly written software? #graphs #swe #dependencyhell #python
To view or add a comment, sign in
-
-
Tired of manually copying event details from flyers into your calendar? I just published a new article on Medium showing how to automate this task using Python, VSCode, and Llama's local GLM-OCR vision model. In this tutorial, you'll learn how to build a 100% free, private, and offline tool to extract structured JSON data from images in less than 100 lines of code. Check out the full guide here: https://lnkd.in/ewSamveh #Python #AI #Automation #Ollama #Coding #LLM
To view or add a comment, sign in
-
Your build server is running out of space. You run df -h. 94% full. Great. So you du -sh your way through directories like it's 2005, mentally adding up numbers, until you finally find the 6 .venv folders nobody cleaned up. There's a better way — and building it yourself is half the point. In my latest article, I walk through building pydusk: a terminal disk usage analyzer in Python, inspired by ncdu. Keyboard-driven, non-blocking, with a delete confirmation flow and a clean TUI — all in a single file with two dependencies. Stack: Textual · Typer · os.scandir Things worth stealing from this project even if you never run it: → Why os.scandir beats os.walk for disk traversal → Textual's @work(thread=True) pattern for background tasks → ModalScreen[T] + dismiss() for confirmation dialogs https://lnkd.in/dmKvDSgH #Python #Textual #CLI #OpenSource #Developer
To view or add a comment, sign in
-
I used to think strings were the “easy” part of Python… today proved me wrong. 🐍 Day 04 of my #30DaysOfPython journey was all about strings, and honestly, this topic felt way more powerful than I expected. A string is basically any data written as text — and it can be written using single quotes, double quotes, or triple quotes. Triple quotes also make multiline strings super easy. Today I explored: 1. len() to check length 2. Concatenation to join strings together 3. Escape sequences like \\n, \\t, \\\\, \\', \\" 4. Old style formatting with %s, %d, %f 5. New style formatting with {} 6. Indexing and unpacking characters 7. Reversing a string with str[::-1] And then came the string methods… that part felt like unlocking a toolbox: capitalize(), count(), startswith(), endswith(), find(), rfind(), format(), index(), rindex(), isalnum(), isalpha(), isdigit(), isnumeric(), isidentifier(), islower(), isupper(), join(), strip(), replace(), split(), title(), swapcase() What hit me today was this: strings are everywhere. Names, messages, input from users, file data, logs, even the little things we ignore at first. So yeah — not “just text.” More like one of the most important building blocks in programming. Github Link - https://lnkd.in/gUkeREkz What was the first Python topic that looked simple but turned out to have way more depth than expected? #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
To view or add a comment, sign in
-
🧠 Python Concept: sorted() vs sort() ✨ Both sort data, but they behave differently. ✨ sorted() → Returns a new sorted list numbers = [5, 2, 8, 1] result = sorted(numbers) print(numbers) # Original list print(result) # Sorted list Output [5, 2, 8, 1] [1, 2, 5, 8] The original list stays unchanged. ✨ list.sort() → Sorts in place numbers = [5, 2, 8, 1] numbers.sort() print(numbers) Output [1, 2, 5, 8] The original list is modified. 🧒 Simple Explanation 📚 Imagine arranging books 📚 sorted() → makes a new sorted pile 📚 sort() → rearranges the same pile 💡 Why This Matters ✔ Understand side effects ✔ Avoid unexpected bugs ✔ Cleaner data processing ✔ Common interview question 🐍 In Python, sorted() and sort() look similar but behave differently 🐍 One creates a new list, the other modifies the existing one. #Python #PythonTips #PythonTricks #AdvancedPython #CleanCode #LearnPython #Programming #DeveloperLife #DailyCoding #100DaysOfCode
To view or add a comment, sign in
-
-
In Python, everything is an object. That one fact broke my mental model this week. I'm transitioning from Software engineering to AI engineering. Week 1, Day 7 🗓️ Here's what clicked 😲. Since everything in Python is an object, every object has a unique memory address. Dict uses this to store and find values in O(1). It hashes the key, jumps directly to the slot. No scanning. No searching. But this only works if the key never changes. A mutable key changes its hash, changes its slot, and your value becomes permanently unreachable. Silent corruption 🤯 . So dict keys must be immutable. And immutable means hashable. Hashable objects carry two methods that work as a pair: __hash__() generates the slot number & __eq__() confirms the exact key at that slot. Override one without the other and Python punishes you: ``` class BrokenDog: def __eq__(self, other): return self.name == other.name # forgot __hash__ hash(BrokenDog("Rex")) # ❌ TypeError: unhashable type ``` But Python's built-in types like dict and str already override __eq__() to compare contents and not addresses. That's why two dicts with identical keys and values return True on `==`. One more thing that surprised me. Since every object in Python carries this overhead of creation, hashing, and storage, even a simple `int` is not free. That's exactly why NumPy exists to escape Python's object model and work directly with raw memory for numerical computation. For more details, refer: https://lnkd.in/gZCGFRBB What's the Python concept that surprised you most when you first learned it? #AIEngineering #Python #LearningInPublic #CareerTransition #SoftwareEngineering
To view or add a comment, sign in
-
Today I explored some important concepts in NumPy, I learned 👇 1. Arrays NumPy arrays are lists of numbers used for fast mathematical operations. Example: Python import numpy as np arr = np.array([1, 2, 3]) 🔹 2. Broadcasting Broadcasting means applying one value to all elements in the array automatically. Example: Python np.array([1,2,3]) + 5 # → [6 7 8] 🔹 3. Axis Axis tells which direction an operation runs. axis=0 → column-wise axis=1 → row-wise Example: Python arr.sum(axis=0) 🔹 4. Slicing Slicing means cutting a part of an array. Example: Python arr = np.array([10,20,30,40]) arr[1:3] # → [20 30] 🔹 5. Stacking Stacking means joining arrays. Example: Python np.hstack((a, b)) np.vstack((a, b)) 🔹 6. Random Values NumPy can create random numbers easily. Example: Python np.random.rand(2,3) 🔹 7. Reshape Reshape changes the shape of an array without changing data. Example: Python np.arange(6).reshape(2,3) # → [[0 1 2] # [3 4 5]]
To view or add a comment, sign in
-
Today’s Python breakthrough: Rethinking the Fibonacci sequence. I started with a Recursive (Top-Down) approach—it looks clean but recalculates the same values repeatedly. It's fine for small numbers, but a nightmare for scaling. I moved to Tabulation (Bottom-Up). By using a list to store results as I go: ✅ Time complexity dropped from O(2 n) to O(n). ✅ No more redundant calculations. ✅ The code actually scales. As an economist moving into Data Science, these efficiency wins are what I love most. It’s not just about getting the right answer; it’s about the most effective way to get there. Check out the clean code here: https://lnkd.in/dgw_sRVM #Python #DataScience #BuildInPublic #DynamicProgramming #WomenInTech
To view or add a comment, sign in
Explore related topics
- Python LLM Development Process
- Building AI Applications with Open Source LLM Models
- Using LLMs as Microservices in Application Development
- LLM Coding Workflow Best Practices
- Best Open-Source Libraries for LLMOps
- Comparing Open-Source LLMs and Advanced Reasoning Models
- Building Machine Learning Models Using LLMs
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development