How Robust are LLM-Generated Library Imports? An Empirical Study using Stack Overflow

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Latendresse, Jasmine, Khatoonabadi, SayedHassan, Shihab, Emad
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912524530614272
author Latendresse, Jasmine
Khatoonabadi, SayedHassan
Shihab, Emad
author_facet Latendresse, Jasmine
Khatoonabadi, SayedHassan
Shihab, Emad
contents 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 mismatches between import names and installable packages, and only two models (out of six) provided installation guidance. While the generated code is technically valid, the lack of contextual support places the burden of manually resolving dependencies on the user. Our findings offer actionable insights for both developers and researchers, and highlight opportunities to improve the reliability and usability of LLM-generated code in the context of software dependencies.
format Preprint
id arxiv_https___arxiv_org_abs_2507_10818
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle How Robust are LLM-Generated Library Imports? An Empirical Study using Stack Overflow
Latendresse, Jasmine
Khatoonabadi, SayedHassan
Shihab, Emad
Software Engineering
Artificial Intelligence
Machine Learning
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 mismatches between import names and installable packages, and only two models (out of six) provided installation guidance. While the generated code is technically valid, the lack of contextual support places the burden of manually resolving dependencies on the user. Our findings offer actionable insights for both developers and researchers, and highlight opportunities to improve the reliability and usability of LLM-generated code in the context of software dependencies.
title How Robust are LLM-Generated Library Imports? An Empirical Study using Stack Overflow
topic Software Engineering
Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2507.10818