[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-345127-105":59,"doc-detail-345127-en":131,"doc-similar-345127":162},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":124,"head_meta":126,"extra_data":128,"updated_unix":130},105,"en","lab-6-language-models","Lab 6 - Language Models","","Lab 6 focuses on using transformer-based language modeling by treating language as a time series, where each word position corresponds to a time step and word representations capture temporal vector dynamics. It introduces recursive next-word prediction as a generation strategy, then explains numerical word representations via word embeddings and a practical indexing scheme. The lab further builds richer embeddings using a cooccurrence matrix, counting joint occurrences of words within a sliding context window and using these statistics to form structure for downstream learning.",{"@graph":69,"@context":123},[70,84,106],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":40,"@type":76,"position":81},"https://docshare.wps.com/document/research-report/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/lab-6-language-models/345127/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/lab-6-language-models/345127.png","ImageObject",300,407,{"name":92,"@type":93},"Pentious","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-30","2026-09-22",true,{"@type":102,"interactionType":103,"userInteractionCount":105},"InteractionCounter",{"@type":104},"ViewAction",14,{"@type":107,"mainEntity":108},"FAQPage",[109,115,119],{"name":110,"@type":111,"acceptedAnswer":112},"How does the lab interpret language when building a language model?","Question",{"text":113,"@type":114},"It treats language as a time series, where each word in a sentence corresponds to a different time step and is represented by a vector.","Answer",{"name":116,"@type":111,"acceptedAnswer":117},"What role do word embeddings play in the lab?",{"text":118,"@type":114},"Word embeddings convert words into numerical vectors; the lab first illustrates index-vector representations and then motivates more useful embeddings.",{"name":120,"@type":111,"acceptedAnswer":121},"How is the cooccurrence matrix constructed in this lab?",{"text":122,"@type":114},"It scans the corpus using a sliding window of length W+1 and counts how often word ej appears in the window centered at word ei, forming Cij as those joint occurrence counts.","https://schema.org",{"og:url":83,"og:type":125,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":127,"canonical":83},"index,follow",{"doc_id":129,"site_id":62},345127,1790740707,{"code":4,"msg":5,"data":132},{"doc_id":129,"user_id":133,"nickname":92,"user_avatar":134,"doc_module":4,"category_id":39,"category_name":40,"doc_title":65,"doc_description":67,"doc_content":135,"file_id":136,"file_url":137,"file_type":138,"file_size":139,"view_count":105,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":46,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":144,"read_time":31,"preview_page_count":19,"preview_urls":145},1374404730887,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","Lab 6: Language Models  \nJavier Porras-Valenzuela and Alejandro Ribeiro  \nJune 2, 2025  \n1 Language Sequences  \nWe can think of language as a time series. In this interpretation, each word in a sentence corresponds to the equivalent of a different point in time and the words themselves represent different vectors of the time series. Consider as an example the first lines spoken by Miranda in The Tempest1 :  \nIf by your art, my dearest father, you have put the wild waters in this roar, allay them.  \nWe can, as we illustrate in Figure 1, parse this sentence as a time series. In this time series the first vector is x0 = “If”, the second vector is x1 = “by”, the third is x2 = “your”, and so on.  \nIf we interpret language as a time series, we can use a transformer to predict the next word in a sequence as we did in Chapter 5 . If we then execute this predictor recursively, we can use it to predict several words in a sequence. This is a strategy for generating language.  \nThe first challenge to implement this strategy is how to represent words numerically. We do that with word embeddings as we discuss in the following section.  \n1In honor of the best Miranda.  \nIf by your art , my dearest father , you have put  \nFigure 1. Language is a Time Series. We parse sentences as time series in which each word corresponds to the equivalent of a different point in time and the words themselves represent different vectors of the time series.  \n2 Word Embeddings  \nA simple approach is to encode words in the index of a long vector. Formally, suppose that we are given a collection of texts that collectively contain a total of c words. We then consider a set of c vectors ei whose length is also c. These vector have all zero entries except for the ith entry which we set to 1,  \n(ei)i = 1 and (ei)j = 0 for i  j. (1)  \nWe use the vector ei to encode the ith word in the corpus.  \nIn corpuses used in practice we have thousands of different words and anywhere between hundreds of thousands to trillions of sentences. In this lab we work with a subset of Shakespeare’s plays which contains c = 14, 295 different words and a total of 292,072 words in the corpus. But to illustrate ideas let us work with a corpus made up of just two quotes:  \nIf by your art, my dearest father, you have put the wild waters in this roar, allay them.  \nSir, are not you my father?  \nIn this corpus we have a total of 24 different words including 3 punctuation marks. We therefore represent the words in the corpus with c = 24 vectors of length c = 24. Proceeding in the order of the sentence, the vector e1 = [1, 0, . . . , 0] represents the word “If,” The vector  \ne2 = [0, 1, 0, . . . , 0] represents the word “by” and so on. The word “father”is the eight word that appears in the sentence and is therefore represented by the vector e8. This vector’s value at index 8 is (e8)8 = 1 and all of its other entries are zero.  \nWhen the same word appears again in the corpus, we encode it with the same vector. E.g., when the word “father” appears a second time we still encode it with the vector e8. This also happens with the comma (“,”) which appears three times and is encoded with the vector e5 in all three appearances and with the words “my” and “you” that appear twice and are encoded in the vectors e6 and e9. So encoded, our corpus becomes:  \ne1 e2 e3 e4 e5 e6 e7 e8 e5 e9 e10 e11 e12 e13 e14 e15 e16 e17 e5 e18 e19 e20  \ne21 e5 e22 e23 e9 e6 e8 e24  \nThis is a defilement of Shakespeare’s work. However, this representation of the corpus can be processed with numerical techniques.  \nEncoding language with these index vectors is not creative and does not work well. We discuss more interesting and useful word embeddings in the next section.  \nTask 1 Get the data for this lab [from](from dsd.seas.upenn.edu/lab6)[ dsd.seas.upenn.edu/lab6](from dsd.seas.upenn.edu/lab6) and load it to your environment. This is a text file containing around 40,000 lines of dialogue from Shakespeare’s plays. Split the text","cbCaiurBmo411zsO","https://ap.wps.com/l/cbCaiurBmo411zsO","pdf",323375,"English","# 1 Language Sequences\n# 2 Word Embeddings\n## 2.1 Cooccurrence Matrices","[{\"question\":\"How does the lab interpret language when building a language model?\",\"answer\":\"It treats language as a time series, where each word in a sentence corresponds to a different time step and is represented by a vector.\"},{\"question\":\"What role do word embeddings play in the lab?\",\"answer\":\"Word embeddings convert words into numerical vectors; the lab first illustrates index-vector representations and then motivates more useful embeddings.\"},{\"question\":\"How is the cooccurrence matrix constructed in this lab?\",\"answer\":\"It scans the corpus using a sliding window of length W+1 and counts how often word ej appears in the window centered at word ei, forming Cij as those joint occurrence counts.\"}]","Lab 6 - Language Models | PDF",1790056585,[146,150,154,158],{"page_no":8,"url":147,"width":148,"height":149},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/034800653e538c6a9efe7fa1420d371d.webp",983,1272,{"page_no":14,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/fc9e773300f57e99520a7b1b81117fc9.webp",982,1270,{"page_no":81,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/551e98fc82f7f0c6e595f649b0894327.webp",981,1269,{"page_no":19,"url":159,"width":160,"height":161},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/54245b211c630343f7ae694155c07063.webp",980,1268,{"list":163,"token":66},[164,171,177,183,189,196,202,208,215,222],{"doc_id":165,"doc_title":166,"file_type":138,"home_preview_img_url":167,"slug":168,"view_count":169,"category_name":40,"create_tm":170},138563,"CALE : Concept-Aligned Embeddings for Both Within-Lemma and Inter-Lemma Sense Differentiation","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229864127694/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=ZJP%2F0GlWDe0Hf6WXL5H%2FqzHfZbw%3D","cale-concept-aligned-embeddings-for-both-within-lemma-and-inter-lemma-sense-differentiation",16,1787483879,{"doc_id":172,"doc_title":173,"file_type":138,"home_preview_img_url":174,"slug":175,"view_count":34,"category_name":40,"create_tm":176},460744,"pCPPs-sADNN - predicting cell penetrating peptides using self-attention based deep neural network","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926017617/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=R7igA8uQSg%2BRSkrRZExe%2B9Zrz%2Fo%3D","pcpps-sadnn-predicting-cell-penetrating-peptides-using-self-attention-based-deep-neural-network",1790759383,{"doc_id":178,"doc_title":179,"file_type":138,"home_preview_img_url":180,"slug":181,"view_count":44,"category_name":40,"create_tm":182},417810,"RiverText - A Python Library for Training and Evaluating Incremental Word Embeddings from Text Data Streams","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229922495916/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=KJn3n0zVt9PNwS8OeRGytlc3B9M%3D","rivertext-a-python-library-for-training-and-evaluating-incremental-word-embeddings-from-text-data-streams",1790610697,{"doc_id":184,"doc_title":185,"file_type":138,"home_preview_img_url":186,"slug":187,"view_count":56,"category_name":40,"create_tm":188},155872,"Symbolic and distributed word representations - PhD dissertation","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229869967983/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=dI7oLNRYLosSs52NCfBK6r1yML0%3D","symbolic-and-distributed-word-representations-phd-dissertation",1787929757,{"doc_id":190,"doc_title":191,"file_type":138,"home_preview_img_url":192,"slug":193,"view_count":194,"category_name":40,"create_tm":195},489786,"A Comparative Study on Language Models for the Kannada Language","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229927535552/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=FfUZnWT3sxUUmHs0lJM2zjcuzXE%3D","a-comparative-study-on-language-models-for-the-kannada-language",15,1790827391,{"doc_id":197,"doc_title":198,"file_type":138,"home_preview_img_url":199,"slug":200,"view_count":19,"category_name":40,"create_tm":201},655826,"Advancing Class Diagram Extraction from Requirement Text - A Transformer-Based Approach","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229974778417/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=rNh8D4qSJ8zcbBSjx5zXMcvrYSI%3D","advancing-class-diagram-extraction-from-requirement-text-a-transformer-based-approach",1792964136,{"doc_id":203,"doc_title":204,"file_type":138,"home_preview_img_url":205,"slug":206,"view_count":29,"category_name":40,"create_tm":207},493337,"Detecting Hacker Threats - Performance of Word and Sentence Embedding Models in Identifying Hacker Communications - a Study","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229928768063/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=KfIL3x6AyG5iMdxS3582z3ZR4do%3D","detecting-hacker-threats-performance-of-word-and-sentence-embedding-models-in-identifying-hacker-communications-a-study",1790880512,{"doc_id":209,"doc_title":210,"file_type":138,"home_preview_img_url":211,"slug":212,"view_count":213,"category_name":40,"create_tm":214},140255,"The Curious Case of Absolute Position Embeddings - Paper Findings","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229865801750/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=YsgS8rfrjaWfh6EyLZzkyTbiJs8%3D","the-curious-case-of-absolute-position-embeddings-paper-findings",13,1787571343,{"doc_id":216,"doc_title":217,"file_type":138,"home_preview_img_url":218,"slug":219,"view_count":220,"category_name":40,"create_tm":221},126795,"Current Topological and Machine Learning Applications for Bias Detection in Text","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229839393801/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=NTam8H%2FRqBsNAKCwsn%2FXFtiq0Bg%3D","current-topological-and-machine-learning-applications-for-bias-detection-in-text",22,1785934827,{"doc_id":223,"doc_title":224,"file_type":138,"home_preview_img_url":225,"slug":226,"view_count":227,"category_name":40,"create_tm":228},85616,"Bootstrap Theory of Representational Emergence","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229809276836/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796115179&Signature=CzjEMleAOt1AHoA9Y5yXWZ%2FEfnE%3D","bootstrap-theory-of-representational-emergence",26,1784204950]