Skip to main content
Erschienen in: Automated Software Engineering 1/2024

01.05.2024

Prompt enhance API recommendation: visualize the user’s real intention behind this query

verfasst von: Yong Wang, Linjun Chen, Cuiyun Gao, Yingtao Fang, Yong Li

Erschienen in: Automated Software Engineering | Ausgabe 1/2024

Einloggen

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

Developers frequently rely on APIs in their daily programming tasks, as APIs have become an indispensable tool for program development. However, with a vast number of open-source libraries available, selecting the appropriate API quickly can be a common challenge for programmers. Previous research on API recommendation primarily focused on designing better approaches to interpret user input. However, in practical applications, it is often difficult for users, especially novice programmers, to express their real intentions due to the limitations of language expression and programming capabilities. To address this issue, this paper introduces PTAPI, an approach that visualizes the user’s real intentions based on their query to enhance recommendation performance. Firstly, PTAPI identifies the prompt template from Stack Overflow (SO) posts based on the user’s input. Secondly, the obtained prompt template is combined with the user’s input to generate a new question. Finally, the newly generated question leverages dual information sources from SO posts and API official documentation to provide recommendations. To evaluate the effectiveness of PTAPI, we conducted experiments at both the class-level and method-level. The experimental results demonstrate the effectiveness of the proposed approach, with a significant improvement in the success rate.

Sie haben noch keine Lizenz? Dann Informieren Sie sich jetzt über unsere Produkte:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Literatur
Zurück zum Zitat Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J.D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al.: Language models are few-shot learners. Adv. Neural Inf. Process. Syst. 33, 1877–1901 (2020) Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J.D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al.: Language models are few-shot learners. Adv. Neural Inf. Process. Syst. 33, 1877–1901 (2020)
Zurück zum Zitat Chen, Y., Gao, C., Ren, X., Peng, Y., Xia, X., Lyu, M.R.: API usage recommendation via multi-view heterogeneous graph representation learning. IEEE Trans. Softw. Eng. 49(5), 3289–3304 (2023)CrossRef Chen, Y., Gao, C., Ren, X., Peng, Y., Xia, X., Lyu, M.R.: API usage recommendation via multi-view heterogeneous graph representation learning. IEEE Trans. Softw. Eng. 49(5), 3289–3304 (2023)CrossRef
Zurück zum Zitat Devlin, J., Chang, M.-W., Lee, K., Toutanova, K.: Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805 (2018) Devlin, J., Chang, M.-W., Lee, K., Toutanova, K.: Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:​1810.​04805 (2018)
Zurück zum Zitat Fowkes, J., Sutton, C.: Parameter-free probabilistic api mining across github. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 254–265 (2016) Fowkes, J., Sutton, C.: Parameter-free probabilistic api mining across github. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 254–265 (2016)
Zurück zum Zitat Gao, T., Fisch, A., Chen, D.: Making pre-trained language models better few-shot learners. arXiv preprint arXiv:2012.15723 (2020) Gao, T., Fisch, A., Chen, D.: Making pre-trained language models better few-shot learners. arXiv preprint arXiv:​2012.​15723 (2020)
Zurück zum Zitat Gu, X., Zhang, H., Zhang, D., Kim, S.: Deep API learning. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 631–642 (2016) Gu, X., Zhang, H., Zhang, D., Kim, S.: Deep API learning. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 631–642 (2016)
Zurück zum Zitat Gvero, I.: Core java volume I: fundamentals, 9th edition by cay s. horstmann and gary cornell. ACM SIGSOFT Softw. Eng. Notes 38(3), 33 (2013)CrossRef Gvero, I.: Core java volume I: fundamentals, 9th edition by cay s. horstmann and gary cornell. ACM SIGSOFT Softw. Eng. Notes 38(3), 33 (2013)CrossRef
Zurück zum Zitat Hou, D., Yao, X.: Exploring the intent behind api evolution: a case study. In: 2011 18th Working Conference on Reverse Engineering, pp. 131–140. IEEE (2011) Hou, D., Yao, X.: Exploring the intent behind api evolution: a case study. In: 2011 18th Working Conference on Reverse Engineering, pp. 131–140. IEEE (2011)
Zurück zum Zitat Huang, Q., Xia, X., Xing, Z., Lo, D., Wang, X.: Api method recommendation without worrying about the task-API knowledge gap. In: Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, pp. 293–304 (2018) Huang, Q., Xia, X., Xing, Z., Lo, D., Wang, X.: Api method recommendation without worrying about the task-API knowledge gap. In: Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, pp. 293–304 (2018)
Zurück zum Zitat Irsan, I.C., Zhang, T., Thung, F., Kim, K., Lo, D.: Picaso: Enhancing API recommendations with relevant stack overflow posts. In: 2023 IEEE/ACM 20th International Conference on Mining Software Repositories (MSR), 92–37 (2023) Irsan, I.C., Zhang, T., Thung, F., Kim, K., Lo, D.: Picaso: Enhancing API recommendations with relevant stack overflow posts. In: 2023 IEEE/ACM 20th International Conference on Mining Software Repositories (MSR), 92–37 (2023)
Zurück zum Zitat Lam, A.N., Nguyen, A.T., Nguyen, H.A., Nguyen, T.N.: Combining deep learning with information retrieval to localize buggy files for bug reports (n). In: 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 476–481 (2015) Lam, A.N., Nguyen, A.T., Nguyen, H.A., Nguyen, T.N.: Combining deep learning with information retrieval to localize buggy files for bug reports (n). In: 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 476–481 (2015)
Zurück zum Zitat Li, Z., Wu, J., Li, M.: Study on key issues in API usage. J. Softw. 29(6), 1716–1738 (2018)MathSciNet Li, Z., Wu, J., Li, M.: Study on key issues in API usage. J. Softw. 29(6), 1716–1738 (2018)MathSciNet
Zurück zum Zitat Ling, C., Zou, Y., Xie, B.: Graph neural network based collaborative filtering for api usage recommendation. In: 2021 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER), pp. 36–47. IEEE (2021) Ling, C., Zou, Y., Xie, B.: Graph neural network based collaborative filtering for api usage recommendation. In: 2021 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER), pp. 36–47. IEEE (2021)
Zurück zum Zitat Liu, X., Zhang, F., Hou, Z., Mian, L., Wang, Z., Zhang, J., Tang, J.: Self-supervised learning: generative or contrastive. IEEE Trans. Knowl. Data Eng. 35(1), 857–876 (2021) Liu, X., Zhang, F., Hou, Z., Mian, L., Wang, Z., Zhang, J., Tang, J.: Self-supervised learning: generative or contrastive. IEEE Trans. Knowl. Data Eng. 35(1), 857–876 (2021)
Zurück zum Zitat Liu, P., Yuan, W., Fu, J., Jiang, Z., Hayashi, H., Neubig, G.: Pre-train, prompt, and predict: a systematic survey of prompting methods in natural language processing. ACM Comput. Surv. 55(9), 195–119535 (2023)CrossRef Liu, P., Yuan, W., Fu, J., Jiang, Z., Hayashi, H., Neubig, G.: Pre-train, prompt, and predict: a systematic survey of prompting methods in natural language processing. ACM Comput. Surv. 55(9), 195–119535 (2023)CrossRef
Zurück zum Zitat Liu, K., Chen, X., Chen, C., Xie, X., Cui, Z.: Automated question title reformulation by mining modification logs from stack overflow. IEEE Trans. Softw. Eng. 49(9), 4390–4410 (2023)CrossRef Liu, K., Chen, X., Chen, C., Xie, X., Cui, Z.: Automated question title reformulation by mining modification logs from stack overflow. IEEE Trans. Softw. Eng. 49(9), 4390–4410 (2023)CrossRef
Zurück zum Zitat Loper, E., Bird, S.: Nltk: The natural language toolkit. arXiv preprint cs/0205028 (2002) Loper, E., Bird, S.: Nltk: The natural language toolkit. arXiv preprint cs/0205028 (2002)
Zurück zum Zitat Mikolov, T., Sutskever, I., Chen, K., Corrado, G.S., Dean, J.: Distributed representations of words and phrases and their compositionality. Adv. Neural Inf. Process. Syst. 26 (2013) Mikolov, T., Sutskever, I., Chen, K., Corrado, G.S., Dean, J.: Distributed representations of words and phrases and their compositionality. Adv. Neural Inf. Process. Syst. 26 (2013)
Zurück zum Zitat Nguyen, P.T., Di Rocco, J., Di Ruscio, D., Ochoa, L., Degueule, T., Di Penta, M.: Focus: A recommender system for mining api function calls and usage patterns. In: 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE), pp. 1050–1060 (2019) Nguyen, P.T., Di Rocco, J., Di Ruscio, D., Ochoa, L., Degueule, T., Di Penta, M.: Focus: A recommender system for mining api function calls and usage patterns. In: 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE), pp. 1050–1060 (2019)
Zurück zum Zitat Nguyen, A.T., Hilton, M., Codoban, M., Nguyen, H.A., Mast, L., Rademacher, E., Nguyen, T.N., Dig, D.: API code recommendation using statistical learning from fine-grained changes. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 511–522 (2016) Nguyen, A.T., Hilton, M., Codoban, M., Nguyen, H.A., Mast, L., Rademacher, E., Nguyen, T.N., Dig, D.: API code recommendation using statistical learning from fine-grained changes. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 511–522 (2016)
Zurück zum Zitat Ponzanelli, L., Mocci, A., Bacchelli, A., Lanza, M., Fullerton, D.: Improving low quality stack overflow post detection. In: 2014 IEEE International Conference on Software Maintenance and Evolution, pp. 541–544 (2014) Ponzanelli, L., Mocci, A., Bacchelli, A., Lanza, M., Fullerton, D.: Improving low quality stack overflow post detection. In: 2014 IEEE International Conference on Software Maintenance and Evolution, pp. 541–544 (2014)
Zurück zum Zitat Radford, A., Narasimhan, K., Salimans, T., Sutskever, I., et al.: Improving language understanding by generative pre-training (2018) Radford, A., Narasimhan, K., Salimans, T., Sutskever, I., et al.: Improving language understanding by generative pre-training (2018)
Zurück zum Zitat Rahman, M.M., Roy, C.K., Lo, D.: RACK: automatic API recommendation using crowdsourced knowledge. CoRR abs/1807.02953 (2018) Rahman, M.M., Roy, C.K., Lo, D.: RACK: automatic API recommendation using crowdsourced knowledge. CoRR abs/1807.02953 (2018)
Zurück zum Zitat Sacramento, P., Cabral, B., Marques, P.: Unchecked exceptions: Can the programmer be trusted to document exceptions. IVNET’06 (2006) Sacramento, P., Cabral, B., Marques, P.: Unchecked exceptions: Can the programmer be trusted to document exceptions. IVNET’06 (2006)
Zurück zum Zitat Saha, R.K., Lease, M., Khurshid, S., Perry, D.E.: Improving bug localization using structured information retrieval. In: 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 345–355 (2013) Saha, R.K., Lease, M., Khurshid, S., Perry, D.E.: Improving bug localization using structured information retrieval. In: 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 345–355 (2013)
Zurück zum Zitat Sarwar, B., Karypis, G., Konstan, J., Riedl, J.: Item-based collaborative filtering recommendation algorithms. In: Proceedings of the 10th International Conference on World Wide Web, pp. 285–295 (2001) Sarwar, B., Karypis, G., Konstan, J., Riedl, J.: Item-based collaborative filtering recommendation algorithms. In: Proceedings of the 10th International Conference on World Wide Web, pp. 285–295 (2001)
Zurück zum Zitat Scarselli, F., Gori, M., Tsoi, A.C., Hagenbuchner, M., Monfardini, G.: The graph neural network model. IEEE Trans. Neural Netw. 20(1), 61–80 (2008)CrossRef Scarselli, F., Gori, M., Tsoi, A.C., Hagenbuchner, M., Monfardini, G.: The graph neural network model. IEEE Trans. Neural Netw. 20(1), 61–80 (2008)CrossRef
Zurück zum Zitat Shin, T., Razeghi, Y., Logan IV, R.L., Wallace, E., Singh, S.: Autoprompt: Eliciting knowledge from language models with automatically generated prompts. arXiv preprint arXiv:2010.15980 (2020) Shin, T., Razeghi, Y., Logan IV, R.L., Wallace, E., Singh, S.: Autoprompt: Eliciting knowledge from language models with automatically generated prompts. arXiv preprint arXiv:​2010.​15980 (2020)
Zurück zum Zitat Su, X., Khoshgoftaar, T.M.: A survey of collaborative filtering techniques. Adv. Artif. Intell. 2009 (2009) Su, X., Khoshgoftaar, T.M.: A survey of collaborative filtering techniques. Adv. Artif. Intell. 2009 (2009)
Zurück zum Zitat Thung, F.: Api recommendation system for software development. In: Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering, pp. 896–899 (2016) Thung, F.: Api recommendation system for software development. In: Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering, pp. 896–899 (2016)
Zurück zum Zitat Wang, J., Dang, Y., Zhang, H., Chen, K., Xie, T., Zhang, D.: Mining succinct and high-coverage api usage patterns from source code. In: 2013 10th Working Conference on Mining Software Repositories (MSR), pp. 319–328. IEEE (2013) Wang, J., Dang, Y., Zhang, H., Chen, K., Xie, T., Zhang, D.: Mining succinct and high-coverage api usage patterns from source code. In: 2013 10th Working Conference on Mining Software Repositories (MSR), pp. 319–328. IEEE (2013)
Zurück zum Zitat Wang, X., Zhou, K., Wen, J.-R., Zhao, W.X.: Towards unified conversational recommender systems via knowledge-enhanced prompt learning. In: Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pp. 1929–1937 (2022) Wang, X., Zhou, K., Wen, J.-R., Zhao, W.X.: Towards unified conversational recommender systems via knowledge-enhanced prompt learning. In: Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, pp. 1929–1937 (2022)
Zurück zum Zitat Wei, M., Harzevili, N.S., Huang, Y., Wang, J., Wang, S.: Clear: contrastive learning for API recommendation. In: Proceedings of the 44th International Conference on Software Engineering, pp. 376–387 (2022) Wei, M., Harzevili, N.S., Huang, Y., Wang, J., Wang, S.: Clear: contrastive learning for API recommendation. In: Proceedings of the 44th International Conference on Software Engineering, pp. 376–387 (2022)
Zurück zum Zitat Wen, M., Wu, R., Cheung, S.-C.: Locus: Locating bugs from software changes. In: Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering, pp. 262–273 (2016) Wen, M., Wu, R., Cheung, S.-C.: Locus: Locating bugs from software changes. In: Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering, pp. 262–273 (2016)
Zurück zum Zitat Xie, T., Pei, J.: Mapo: mining API usages from open source repositories. In: Proceedings of the 2006 International Workshop on Mining Software Repositories, pp. 54–57 (2006) Xie, T., Pei, J.: Mapo: mining API usages from open source repositories. In: Proceedings of the 2006 International Workshop on Mining Software Repositories, pp. 54–57 (2006)
Zurück zum Zitat Yu, Z., Bai, C., Seinturier, L., Monperrus, M.: Characterizing the usage, evolution and impact of java annotations in practice. IEEE Trans. Softw. Eng. 47(5), 969–986 (2021)CrossRef Yu, Z., Bai, C., Seinturier, L., Monperrus, M.: Characterizing the usage, evolution and impact of java annotations in practice. IEEE Trans. Softw. Eng. 47(5), 969–986 (2021)CrossRef
Zurück zum Zitat Zanjani, M.B., Kagdi, H., Bird, C.: Automatically recommending peer reviewers in modern code review. IEEE Trans. Softw. Eng. 42(6), 530–543 (2015)CrossRef Zanjani, M.B., Kagdi, H., Bird, C.: Automatically recommending peer reviewers in modern code review. IEEE Trans. Softw. Eng. 42(6), 530–543 (2015)CrossRef
Zurück zum Zitat Zhang, J., Jiang, H., Ren, Z., Chen, X.: Recommending APIs for API related questions in stack overflow. IEEE Access 6, 6205–6219 (2017)CrossRef Zhang, J., Jiang, H., Ren, Z., Chen, X.: Recommending APIs for API related questions in stack overflow. IEEE Access 6, 6205–6219 (2017)CrossRef
Zurück zum Zitat Zhou, Y., Yang, X., Chen, T., Huang, Z., Ma, X., Gall, H.: Boosting API recommendation with implicit feedback. IEEE Trans. Softw. Eng. 48(6), 2157–2172 (2022)CrossRef Zhou, Y., Yang, X., Chen, T., Huang, Z., Ma, X., Gall, H.: Boosting API recommendation with implicit feedback. IEEE Trans. Softw. Eng. 48(6), 2157–2172 (2022)CrossRef
Metadaten
Titel
Prompt enhance API recommendation: visualize the user’s real intention behind this query
verfasst von
Yong Wang
Linjun Chen
Cuiyun Gao
Yingtao Fang
Yong Li
Publikationsdatum
01.05.2024
Verlag
Springer US
Erschienen in
Automated Software Engineering / Ausgabe 1/2024
Print ISSN: 0928-8910
Elektronische ISSN: 1573-7535
DOI
https://doi.org/10.1007/s10515-024-00425-0

Weitere Artikel der Ausgabe 1/2024

Automated Software Engineering 1/2024 Zur Ausgabe

Premium Partner