ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ......
Transcript of ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ......
![Page 1: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/1.jpg)
Information Retrieval
![Page 2: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/2.jpg)
ค้นคืน คือ ค้นอะไร คืนอะไร
• วิธีการใช้ Dictionary บน Python
• หนังสือเรื่อง อยู่กับก๋ง
• อีเมล์เชิญไปสัมภาษณ์งาน
• รูปภาพของเฌอปราง
• รถไฟฟ้าเปิดกี่โมง
![Page 3: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/3.jpg)
Information Retrieval การค้นคืนข้อมูล
• การค้นหาเนื้อหาจากกองข้อมูลที่ตอบโจทยค์วามต้องการทางข้อมูล (Information need)
![Page 4: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/4.jpg)
Classic Search Model
Information Need
Query
Search Engine
Results
Documentcollection
![Page 5: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/5.jpg)
NLP + Information Retrieval
• "รถไฟฟ้าเปิดกี่โมง" --->
• "รถไฟฟ้าเปิดกี่โมง" ---> รถไฟฟ้า BTS สายสุขุมวิทเปิดเวลา 5:15
![Page 6: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/6.jpg)
![Page 7: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/7.jpg)
Document เอกสาร
• วิธีการใช้ Dictionary บน Python
• หนังสือเรื่อง อยู่กับก๋ง
• อีเมล์เชิญไปสัมภาษณ์งาน
• รูปภาพของเฌอปราง
• รถไฟฟ้าเปิดกี่โมง
![Page 8: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/8.jpg)
![Page 9: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/9.jpg)
Challenges
• ทําความเข้าใจ query และ document เพื่อสนองความต้องการทาง
ข้อมูลของผู้ใช้
• ต้องทําให้ได้เร็ว (อย่าเกิน 1-2 วินาที)
• ต้องอย่าเปลืองที่เก็บข้อมูลและเครื่องคอมพ์
![Page 10: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/10.jpg)
Boolean Retrieval
![Page 11: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/11.jpg)
Search แบบง่ายสุด
• อยากหาไฟล์ที่มีคําว่า Caesar และคําว่า Brutusgrep 'Caesar' docs/*.txt | grep 'Brutus'
• อยากหาไฟล์ที่มีคําว่า Caesar และ Brutus แต่ไม่มีคําว่า Calpurnia
![Page 12: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/12.jpg)
![Page 13: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/13.jpg)
Term-Doc Matrix ในความเป็นจริง
• N = 1 ล้าน document แต่ละ doc มี 1000 คํา
• ค่าเก็บข้อมูล
• ตัวอักษรละ 1 byte คํานึงมีประมาณ 6 ตัวอักษรโดยเฉลี่ย
• ต้องใช้ Hard drive ขนาด 1 byte x 6 x 1000 x 1M = 6000MB = 6GB
• ค่าเก็บข้อมูล term-doc matrix
![Page 14: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/14.jpg)
• 4 bytes x 1M document x 100,000 (vocab size) = 400GB 99% ของ 400GB เก็บแต่ 0 เอาไว้
![Page 15: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/15.jpg)
Inverted Index
![Page 16: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/16.jpg)
Inverted Index
• datat structure ที่เป็น sparse matrix แบบหนึ่ง search engine
ทุกประเภทบนโลกนี้ยังใช้กันอยู่
• จุดมุ่งหมาย คือ ประหยัดที่และประหยัดเวลา
![Page 17: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/17.jpg)
Inverted Index
![Page 18: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/18.jpg)
![Page 19: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/19.jpg)
![Page 20: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/20.jpg)
![Page 21: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/21.jpg)
Brutus and Calpurnia
![Page 22: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/22.jpg)
![Page 23: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/23.jpg)
Linguistic Processing of Documents
![Page 24: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/24.jpg)
From words to terms
• แปลงเอกสาร (e.g. email, PDF, word doc) ให้เป็น text file ธรรมดา
• Tokenize: honey-roasted pork
• Normalization: U.S.A, USA —> usa; naïve, naive —> naive
• Stemming: authorization, authorize, authorized —> authoriz
• Stopwords: the, a, to, of, in —> X
![Page 25: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/25.jpg)
Tokenize ภาษาไทย: ผลิตรายการ
• Word segmentation with Machine Learning : ผลิต, รายการ
• Dictionary : ผลิต, ราย, การ, ลิตร
• Character cluster: ผลิต, ราย, การ
• Character ngrams: ผล ลิต ตร รา ยก กา ผลิ ลิตร ตรา ราย ยาก การ
![Page 26: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/26.jpg)
Thai Character Cluster
![Page 27: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/27.jpg)
From words to terms
• แปลงเอกสาร (e.g. email, PDF, word doc) ให้เป็น text file ธรรมดา
• Tokenize
• Normalization
• Stemming
• Stopwords
![Page 28: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/28.jpg)
Phrase Queries
![Page 29: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/29.jpg)
Phrase Query
• หา document ที่มีคําว่า Stanford University อยู่ติดกัน
• ไม่เอา doc "I went to university at Stanford"
![Page 30: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/30.jpg)
![Page 31: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/31.jpg)
Phrase query ที่ยาวกว่า 2 คํา
• Stanford University Palo Alto —>"Stanford University" AND "University Palo" AND "Palo Alto"
![Page 32: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/32.jpg)
Biword Index ไม่ใช่คําตอบ
• Index จะใหญ่เบิ้มมากเสียค่าเก็บ (อย่าลืมว่า RAM แพง)
• ไม่รองรับ phrase ที่ยาวกว่าสองคํา
![Page 33: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/33.jpg)
Positional Index
• (term, freq): [docID, docID, docID, …]
• (term, freq): [docID: [word position, word position, …] , docID: [word position, word position, …] , … ]
![Page 34: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/34.jpg)
![Page 35: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/35.jpg)
Positional Index แพงไปมั้ย
![Page 36: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/36.jpg)
สรุป
• ใช้ทั้งสองอย่างไปเลย
• positional index มันช้า ==> phrase ไหนที่เจอบ่อยๆ ก็เก็บไว้ใน
phrase index (caching)
![Page 37: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/37.jpg)
Ranked Retrieval with TF-IDF
![Page 38: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/38.jpg)
Boolean Search
• ไม่เข้า ก็ออกเลย
• ไม่เยอะไป (ขี้เกียจเปิดอ่านหมด) ก็น้อยไป (ไม่มีสิ่งที่อยากได้)
![Page 39: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/39.jpg)
![Page 40: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/40.jpg)
Relevance Score คะแนนความเกี่ยวข้อง
score(d1,q)=0.81
score(d2,q)=0.74
score(d3,q)=0.68
q=คณะอักษรศาสตร์
![Page 41: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/41.jpg)
ถ้าเห็น term นั้นบ่อย doc นั้นยิ่งคะแนนเยอะ
q=AnthonyBrutus
![Page 42: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/42.jpg)
Term Frequency
• Frequency = Occurrence =
จํานวนครั้งที่เจอ
• f
• tft,d = จํานวนครั้งที่เจอ t ใน d
![Page 43: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/43.jpg)
คําทุกคําไม่ได้เท่าเทียมกัน
• term ที่เห็นบ่อยๆ มักจะไม่ค่อย informative (ไม่ได้ช่วยให้หา
document ได้แม่นยําขึ้น)
• tft,d = ความสําคัญของ term นั้นต่อ document นั้น
• ความสําคัญของ term นั้นโดยทั่วไป?
![Page 44: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/44.jpg)
![Page 45: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/45.jpg)
![Page 46: ir part 1 - GitHub Pages · Classic Search Model Information Need Query Search Engine Results ... • Stopwords: the, a, to, of, in —> X. Tokenize ภาษาไทย: ...](https://reader035.fdocuments.net/reader035/viewer/2022062605/5fcc8f441af19f603e29a57c/html5/thumbnails/46.jpg)
TF-IDF weighting