How Robust are LLM-Generated Library Imports? An Empirical Study using Stack Overflow
Jasmine Latendresse, SayedHassan Khatoonabadi, Emad Shihab

TL;DR
This empirical study evaluates how well six state-of-the-art LLMs recommend Python libraries from Stack Overflow prompts, revealing preferences for third-party libraries, usability gaps, and areas for improving dependency handling.
Contribution
The paper provides a comprehensive analysis of LLMs' library import recommendations, highlighting their tendencies, limitations, and the need for better dependency management support.
Findings
LLMs favor third-party libraries over standard ones
4.6% of libraries could not be automatically resolved
Only two models provided installation guidance
Abstract
Software libraries are central to the functionality, security, and maintainability of modern code. As developers increasingly turn to Large Language Models (LLMs) to assist with programming tasks, understanding how these models recommend libraries is essential. In this paper, we conduct an empirical study of six state-of-the-art LLMs, both proprietary and open-source, by prompting them to solve real-world Python problems sourced from Stack Overflow. We analyze the types of libraries they import, the characteristics of those libraries, and the extent to which the recommendations are usable out of the box. Our results show that LLMs predominantly favour third-party libraries over standard ones, and often recommend mature, popular, and permissively licensed dependencies. However, we also identify gaps in usability: 4.6% of the libraries could not be resolved automatically due to structural…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLibrary Collection Development and Digital Resources · Library Science and Information Systems
