Implicit In-context Learning for Few-Shot Relation Extraction
Abstract
Relation Extraction (RE) is a key task in Natural Language Processing (NLP), aiming to identify semantic relations between entity pairs in text. While previous finetuning-based methods achieve strong performance with sufficient labeled data, their effectiveness drops sharply in low-resource settings. In-Context Learning (ICL) with Large Language Mod-els (LLMs) has emerged as a promising alternative, enabling few-shot learning through few demonstrations. However, ICL suffers from high inference costs due to long input contexts and is sensitive to demonstration format and order, leading to unstable results. To address these limitations, we propose I2CL-RE, a few-shot RE framework based on Implicit Contex-tual Learning. Instead of explicitly concatenating demonstrations, I2CL-RE extracts a unified context representation from support examples and injects it into the hidden states of the LLM during inference. This method maintains the advantages of few-shot learning while signifi-cantly reducing inference overhead—approaching zero-shot efficiency. Experiments on four standard RE benchmarks show that I2CL-RE consistently outperforms traditional ICL meth-ods, both in accuracy and efficiency. The results demonstrate that implicit context integration can offer a more stable and cost-effective solution for relation extraction under low-resource conditions.
References
- Wan, Z., Cheng, F., Mao, Z., Liu, Q., Song, H., Li, J., Kurohashi, S.: Gpt-re: In-context learning for relation extraction using large language models. In: Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing. Association for Computational Linguistics (ACL) (2023)
- Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: Bert: Pre-training of deep bidirectional trans-formers for language understanding. In: Proceedings of the 2019 conference of the North Ameri-can chapter of the association for computational linguistics: human language technologies, volume 1 (long and short papers). pp. 4171–4186 (2019)
- Beltagy, I., Lo, K., Cohan, A.: Scibert: A pretrained language model for scientific text. In: Pro-ceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP). p. 3613. Association for Computational Linguistics (2019)
- Lan, Z., Chen, M., Goodman, S., Gimpel, K., Sharma, P., Soricut, R.: Albert: A lite bert for self-supervised learning of language representations. In: International Conference on Learning Representations
- Zhuang, L., Wayne, L., Ya, S., Jun, Z.: A robustly optimized BERT pre-training approach with post-training. In: Li, S., Sun, M., Liu, Y., Wu, H., Liu, K., Che, W., He, S., Rao, G. (eds.) Proceed-ings of the 20th Chinese National Conference on Computational Linguistics. pp. 1218– 1227. Chi-nese Information Processing Society of China, Huhhot, China (Aug 2021), https://aclanthology.org /2021.ccl-1.108/
- Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., Levy, O., Lewis, M., Zettlemoyer, L., Stoy-anov, V.: Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692 (2019)
- Hoffmann, J., Borgeaud, S., Mensch, A., Buchatskaya, E., Cai, T., Rutherford, E., de Las Casas, D., Hendricks, L.A., Welbl, J., Clark, A., et al.: Training compute-optimal large language models. In: Proceedings of the 36th International Conference on Neural Information Processing Systems. pp. 30016–30030 (2022)
- Dubey, A., Jauhri, A., Pandey, A., Kadian, A., Al-Dahle, A., Letman, A., Mathur, A., Schelten, A., Yang, A., Fan, A., et al.: The llama 3 herd of models. CoRR (2024)
- Li, Z., Xu, Z., Han, L., Gao, Y., Wen, S., Liu, D., Wang, H., Metaxas, D.N.: Implicit in-context learning. arXiv preprint arXiv:2405.14660 (2024)
- Zhou, W., Huang, K., Ma, T., Huang, J.: Document-level relation extraction with adaptive thresh-olding and localized context pooling. In: Proceedings of the AAAI conference on artificial intelli-gence. vol. 35, pp. 14612–14620 (2021)
- Ma, Y., Wang, A., Okazaki, N.: Dreeam: Guiding attention with evidence for improving document-level relation extraction. In: Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics. pp. 1971–1983 (2023)
- Zhang, F., Miao, Q., Cheng, J., Yu, H., Yan, Y., Li, X., Wu, Y.: Srf: Enhancing document-level relation extraction with a novel secondary reasoning framework. In: Proceedings of the 2024 Con-ference on Empirical Methods in Natural Language Processing. pp. 15426–15439 (2024)
- Gao, C., Wang, X., Sun, J.: Ttm-re: Memory-augmented document-level relation extraction. CoRR (2024)
- Zhang, N., Chen, X., Xie, X., Deng, S., Tan, C., Chen, M., Huang, F., Si, L., Chen, H.: Document-level relation extraction as semantic segmentation. In: Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence. pp. 3999–4006. International Joint Conferences on Artificial Intelligence Organization (2021)
- Lu, C., Zhang, R., Sun, K., Kim, J., Zhang, C., Mao, Y.: Anaphor assisted document-level relation extraction. In: Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing. pp. 15453–15464 (2023)
- Gutiérrez, B.J., McNeal, N., Washington, C., Chen, Y., Li, L., Sun, H., Su, Y.: Thinking about gpt-3 in-context learning for biomedical ie? think again. In: Findings of the Association for Com-putational Linguistics: EMNLP 2022. pp. 4497–4512 (2022)
- Liu, J., Shen, D., Zhang, Y., Dolan, W.B., Carin, L., Chen, W.: What makes good in-context exam-ples for gpt-3? In: Proceedings of Deep Learning Inside Out (DeeLIO 2022): The 3rd Workshop on Knowledge Extraction and Integration for Deep Learning Architectures. pp. 100-114 (2022)
- Valmeekam, K., Olmo, A., Sreedharan, S., Kambhampati, S.: Large language models still can’t plan (a benchmark for llms on planning and reasoning about change). In: NeurIPS 2022 Founda-tion Models for Decision Making Workshop
- Wu, Z., Wang, Y., Ye, J., Kong, L.: Self-adaptive in-context learning: An information compres-sion perspective for in-context example selection and ordering. In: Proceedings of the 61st An-nual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). pp. 1423–1436 (2023)
- Wei, J., Wang, X., Schuurmans, D., Bosma, M., Xia, F., Chi, E., Le, Q.V., Zhou, D., et al.: Chain-of-thought prompting elicits reasoning in large language models. Advances in neural information processing systems 35, 24824–24837 (2022)
- Ma, X., Li, J., Zhang, M.: Chain of thought with explicit evidence reasoning for few-shot rela-tion extraction. In: Findings of the Association for Computational Linguistics: EMNLP 2023. pp. 2334–2352 (2023)
- Hendrickx, I., Kim, S.N., Kozareva, Z., Nakov, P., Ó Séaghdha, D., Padó, S., Pennacchiotti, M., Romano, L., Szpakowicz, S.: SemEval-2010 task 8: Multi-way classification of semantic relations between pairs of nominals. In: Erk, K., Strapparava, C. (eds.) Proceedings of the 5th International Workshop on Semantic Evaluation. pp. 33–38. Association for Computational Linguistics, Upp-sala, Sweden (Jul 2010), https://aclanthology.org/S10-1006/
- Zhang, Y., Zhong, V., Chen, D., Angeli, G., Manning, C.D.: Position-aware attention and super-vised data improve slot filling. In: Palmer, M., Hwa, R., Riedel, S. (eds.) Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing. pp. 35–45. Association for Computational Linguistics, Copenhagen, Denmark (Sep 2017). https://doi.org/10.18653/v1/D17-1004, https://aclanthology.org/D17-1004/
- Luan, Y., He, L., Ostendorf, M., Hajishirzi, H.: Multi-task identification of entities, relations, and coreference for scientific knowledge graph construction. In: Riloff, E., Chiang, D., Hocken- maier, J., Tsujii, J. (eds.) Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing. pp. 3219–3232. Association for Computational Linguistics, Brussels, Belgium (Oct-Nov 2018). https://doi.org/10.18653/v1/D18-1360, https://aclanthology.org/D18-1360/