Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Personalized Content Recommender System on Sp...
Search
LINE Developers
March 25, 2019
Technology
2.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Personalized Content Recommender System on Spring
LINE Developers
March 25, 2019
More Decks by LINE Developers
See All by LINE Developers
LINEスタンプのSREing事例集:大きなスパイクアクセスを捌くためのSREing
line_developers
3
2.6k
Java 21 Overview
line_developers
6
1.4k
Code Review Challenge: An example of a solution
line_developers
1
1.7k
KARTEのAPIサーバ化
line_developers
1
650
著作権とは何か?〜初歩的概念から権利利用法、侵害要件まで
line_developers
5
2.4k
生成AIと著作権 〜生成AIによって生じる著作権関連の課題と対処
line_developers
3
2.5k
マイクロサービスにおけるBFFアーキテクチャでのモジュラモノリスの導入
line_developers
9
4.1k
A/B Testing at LINE NEWS
line_developers
3
1.2k
LINEのサポートバージョンの考え方
line_developers
2
1.6k
Other Decks in Technology
See All in Technology
Cloudflare Workers 向けアプリを C# で構築する ~WASM Native AOT への道~
nenonaninu
1
1.2k
10Xに技術的負債をもたらした「2つの境界の歪み」その構造と解消への営み
10xinc
0
2.4k
[Kiro Meetup #7] Kiro Crew Dive Deep
konippi
0
260
登壇の自信を奪う3匹のオバケ / 3 Ghosts That Rob You of Your Confidence in Public Speaking
pauli
9
1.1k
積み重なった技術負債への挑戦 〜初手としての全社ゴト化〜
techtekt
PRO
0
1.6k
データ界隈LT祭 第1回LT登壇
taromatsui_cccmkhd
2
1.5k
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
3
1.2k
AIエージェントの自己改善をどう設計するか / How to Design Self-Improvement for AI Agents
22mi
26
17k
【技術的負債conf】事業成長に伴う技術的負債の説明責任とAIによるモニタリング、認知的負債について
i35_267
3
2.1k
「ピッケル本」日本語版は4.0(第6版)が出版されるべき / pickaxe4-nagoyark05
kakutani
2
280
Goodbye ShellScript, Hello File-based App
shunsock
0
820
ほんとうの信頼性はヒーローが死んでからはじまる / True reliability begins after the hero dies
vtryo
0
110
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
340
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
280
Marketing to machines
jonoalderson
1
5.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.9k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
380
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
990
The Invisible Side of Design
smashingmag
301
52k
Balancing Empowerment & Direction
lara
6
1.3k
Transcript
Personalized Content Recommender System on Spring
About me @hackmylife • ຊ໊ ᬒ थ ௨শ നถ •
։ൃ̐ηϯλʔ > AP3 team • Senior server side engineer • livedoorχϡʔε, LINEΪϑτ, LINE BLOG • LINE Ads Platform • Smart Channel • Spring fest 2018 fall
Smart Channel
• Overview • Architecture • Team Agenda
Overview
Concept Contents Contents
UX
• User͕͍ͬͯΔɺ͋Δ͍ڧ͍རӹͷ͋ΔServiceͷใ • ServiceͰ֤UserʹPersonalizeͯ͠࡞ΒΕͨͷ • ࣄલTest৴Λͯ͠ҰఆͷධՁΛ͑ͳ͚ΕͳΒͳ͍(ޙड़) Contents
• Userʹର͢ΔRecommendΛ֤Service͔ΒूΊΔ • ूΊͨ Contents ΛҰ࣌తʹอଘ͓ͯ͘͠ • RequestΛड͚ͨΒContentsΛRankingͯ͠n݅બΜͰ৴͢Δ ͜ͷαʔϏεͷಛ
Figures MAU 79M RPS 250k Servers 200+ * JP͚ͩͷ
Architecture
None
Java + Spring
• Redis • MySQL • Kafka • Spring boot 2
• lettuce5 • MyBatis + kotlin • Caffeine • fastutil, guava Spec
Application 86 pm servers 40 vm servers MySQL 3 vm
servers Redis 100+ vm instance (Redis cluster) Kafka In-house common (Kafka cluster) Log storage In-house common (Hadoop) Servers
Importer CRS Engine Event Tracker Joiner Learning worker 5ͭͷComponent
CRS Engine Flow Event Tracker Joiner Learning worker Importer LINE
App Contents Contents Imp/Click Log Log Parameter
CRS Engine 1. Importer Event Tracker Joiner Learning worker Importer
LINE App Contents Contents Imp/Click Log Log Parameter
None
• Mapping provider͔Βɺrecommend item ͷID͚ͩΒ͏ • item͕ͲΜͳσʔλΛ͍࣋ͬͯΔ͔͍ ߹ΘͤΔ • Redisʹmapping
ͱ contentsΛstore͢Δ Importer user_id1 \t item_id1, item_id2, item_id3 user_id2 \t item_id3, item_id4 user_id3 \t item_id1, item_id2, item_id6 { "items": [ { "originalId": "12345678", "title": “ࣗͷೳྗΛݟۃΊͯ", "description": "ແཧͳεέδϡʔϧͰମௐΛ่ͯ͠͠·͏ΑΓɺ ૉʹपΓʹཔΓ·͠ΐ͏ɻࠓࣗʹݫͯ͘͠͠͠·͍͕ͪɻ ࣗͷೳྗΛ͑ΔͱࢥͬͨΒঢ়گΛͯ͠ڠྗͯ͠Βͬͯ͘ ͍ͩ͞ɻ", "linkURL": “line://ch/1391620050/z/fortune/detail/2/20181011", "iconURL": “http://example.com/path/to/image1.png" }, ……. ] }
• ֤ServiceͰRecommendΛ࡞ͬͯΒ͏ • ྑ͍RecommendʹڧྗͳDomain͕ࣝඞཁ • ServiceʹΑͬͯࡉ͔͍දࣔͷͨΊͷ͕݅͋Δ Recommend
• Recommendation dataͭ͘Δͷ ML engineer • Master data ཧͯ͠Δͷ Service
side engineer • ୲෦ॺ͕ҧ͏ʢ߹ʹΑͬͯࠃҧ͏ʣ • RecommendΛ࡞ͬͨ࣌ͱ͕࣌ࠩ͋Δ Կނ2ճʹ͚ͯσʔλΛऔΔ͔
• Specͱʹ͔͘ΨνΨνʹݻΊ͓ͯ͘ • Documment͔ͬ͠Γἧ͑ͯӳޠͰॻ͍͓ͯ͘ • ServiceͷࢥతΛͪΌΜͱ͑Δ • جຊతʹࣄલTestΛͯ͠ΫϦΞ͠ͳ͍ͱ͍͚ͳ͍ ؾΛ͚͍ͭͯΔ͜ͱ
• CTRxCTRʹΑΔධՁ • ΞϯέʔτͳͲͷఆੑతධՁ • ্هޓ͍ʹڧ͍૬ؔؔ༗Γ Preliminary test
• RecommendServiceଆͰ࡞ͬͯΒ͏ • Recommend id/dataͷऔಘΛ͍ͯ͠Δ • औಘͨ͠Contentsredisʹશ෦ೖΕΔ • Service࿈ܞલʹ͍ͭ͘ͷνΣοΫ͕͋Δ Importer
·ͱΊ
CRS Engine 2. CRS Engine Event Tracker Joiner Learning worker
Importer LINE App Contents Contents Imp/Click Log Log Parameter
None
• UserຖʹRecommend contentsऔಘ • Frequency cap / mute / opt-outͳͲͰfiltering
• Recommend itemΛRanking্͔ͯ͠Βn݅ฦ͢ • Contextual bandit algorithmsΛ࠾༻ CRS Engine
• Reactive API • RedisAdvancedClusterReactiveCommands • Γ͕ Mono / Flux
• ݸਓతʹ͘͢͝εοΩϦ͔͚͖ͯ Lettuce5
• Reactive Streamsͷpublisher࣮ • Mono࠷େ1ݸͷitemΛѻ͏ • FluxෳͷitemΛѻ͏ Mono/Flux
Mono/Fluxͷྫ targetingRedis.mget(keys) // ͜͜Flux͕ؼͬͯ͘Δ .filter(KeyValue::hasValue) .map(keyValue -> Maps.immutableEntry(extractTargetingType(keyValue.getKey()), keyValue.getValue())) .collectMap(Map.Entry::getKey,
Map.Entry::getValue); // ΓɹMono<Map<String, List<String>>> Key: user_id:news Val: ["65819383620a","48d2872c86c6","293d0a33f938","c43cd18c98f4"] Key: user_id:weather Val: [“1"] -> ͜ΕΛnews, weatherΛkeyͱͨ͠Mapͱ͔ʹͯ͠ฦ͍ͨ͠ ࣮ࡍʹॲཧ͞ΕΔͷsubscribeͨ࣌͠
• Flux͔Βstreaming apiతͳॲཧΛεϜʔζʹ͔͚Δ • ଈॲཧͰͳ͘ॲཧΛޙͰߦ͑Δ • Mono.zip()ͳͲΛͬͯฒྻॲཧͰ͖Δ • ͨͩɺ·ͩͦ͜·Ͱ͍ͬͯͳ͍ Mono/FluxͷϝϦοτ
subtitle Bandit algorithms • SlotͷrewardΛ࠷େԽ͢Δ • ࣄલڞ༗ใ͕ແ͍߹͋Δ • ϥϯυຖʹͲͷarmΛબͿ͔ܾఆ͢Δ •
ϙΠϯτ୳ࡧͱ׆༻Λ͍͚Δ͜ͱ
• ࠷ॳdata͕Γͳ͍ͷͰɺͱΓ͋͑ͣճͯ͠ΈΔʢ୳ࡧʣ • ͋Δఔճ͢ͱ༏ྼ͕ղͬͯ͘Δ • Ұ൪ظ͞ΕΔreward͕ྑ͍ͱ͜ΖΛճ͢ʢ׆༻ʣ • ͬͱใु͕ྑ͍Ϛγϯ͕͋Δ͔୳͢ʢ୳ࡧʣ ୳ࡧͱ׆༻
• RewardͷఆٛUserͷreaction (CTRͱ͔xCTRͱ͔) • UserҰਓҰਓʹarmΛ͚͍͕ͨɺऩଋͣ͠Β͘ͳΔ • ͳͷͰɺ͏গ͠େཻ͖͍Ͱֶश͍ͯ͠Δ • ਫ਼Λ্͛ΔͨΊʹɺ͍͔ͭ͘ใʢ=ContextʣΛ༩͍͑ͯΔ Contextual
bandit on CRS engine
User side • Gender • Age • Interests Contents side
2-side features • Time • Id • Score
• ঁੑ > உੑ • ए͍ੈͷํ͕ؾʹ͢ΔͷͰʁ • உੑͦΜͳʹݟͳ͍ʁ User side
- ͍ Age-range x Gender
• Ͳ͏ͤΈΔͳΒேͩΑͶ • ྑ͍݁Ռͩͱclick͍͢͠ͷͰ • ѱ͍݁Ռݟͨ͘ͳ͍ʁ Contents side - ͍
Age-range x Gender x Hour x Score
LinUCB Bayesian linear regression Bayesian factorization machines Supported Algorithms Bayesian
neural factorization machines
• RedisΛ৭ʑࢀর͍ͯͯ͠Δ • Contextual bandit algorithms ͷRankerͱͯ͠n݅બͿ • BanditͷContext৭ʑ͍ͯ͠Δ CRS
engine ·ͱΊ
CRS Engine 3. Event Tracker Event Tracker Joiner Learning worker
Importer LINE App Contents Contents Imp/Click Log Log Parameter
None
• imp/click/muteͳͲͷeventΛड͚Δ • Ұ୴Kafkaʹproduce͢Δ͚ͩ • consume͢Δcomponent͚ͯͯΔ • KafkaΛ͏ϝϦοτΛ1൪ڗडͰ͖Δ Event tracker
• ߴ͍scalabilityͱavailability • Persistent data • Pub-Subܕ (kafkaͷ༻ޠͱͯ͠produce / consume)
• ෳconsumer͔ΒಡΊΔ Kafka
• eventΛอଘ͢Δॲཧͱɺ࣮ࡍʹԿ ͔͢ΔॲཧΛ͚ΒΕΔ • ผͷconsumer͔ΒಡΊΔ • ো࣌ʹӨڹΛ࠷খݶʹͰ͖Δɺ ಛఆ͘͢͠ͳΔ KafkaͷϝϦοτ
• Spring bootͱ૬ੑ͕ͱͯྑ͍ • @BeanͰKafka-clientΛཧ͢Δͱੜ/ഁغ·Ͱ໘ݟͯ͘ΕΔ • Kafka-streamsͱΈ߹ΘͤΔ͜ͱͰίʔυॻ͘ྔ͕ͱͯগͳ͍ • Spring-kafka͋Δ͚ͲެࣜKafka-client͕Φεεϝ Kafka
on spring
@Configuration @RequiredArgsConstructor @EnableConfigurationProperties({ KafkaStreamsProperties.class, KafkaTopicProperties.class }) public class KafkaStreamsConfiguration {
@Bean public KafkaStreams muteEventStream( KafkaStreamsProperties streamsProperties, KafkaTopicProperties topicProperties ) { final StreamsBuilder builder = new StreamsBuilder(); builder.stream(topicProperties.getMuteEvent(), Consumed.with(new StringSerde(), new StringSerde())) .foreach((key, value) -> { try { // Կ͔ॲཧ } catch (Exception e) { // ྫ֎ॲཧ } }); KafkaStreams streams = new KafkaStreams(builder.build(), streamsProperties.getMuteEventStream()); streams.setUncaughtExceptionHandler((thread, e) -> { log.error("Uncaught exception in StreamThread.", e); }); streams.start(); return streams; } }
kafka: servers: server1, server2, server3 metrics-reporter: com.example.awesome.kafka.metrics.PrometheusMetricsReporter topic: mute-event: awesome-mute-event-v1
stream: mute-event-stream: "bootstrap.servers": ${kafka.servers} "application.id": crs-mute-event "state.dir": /path/to/kafka-streams "num.stream.threads": 6 "replication.factor": 3 "metric.reporters": ${kafka.metrics-reporter} consumer: "max.poll.records": 100 "auto.offset.reset": earliest @ConfigurationProperties(prefix = "kafka.stream") public class KafkaStreamsProperties { @NotNull @Valid private Properties muteEventStream; }
• LINEΞϓϦ͔ΒͷEventΛड͚औΔॲཧ • KafkaΛڬΉ͜ͱͰɺߴ/োੑΛ࣮ݱͯ͠Δ • ݸਓతʹKafkaҰԡ͠Ͱ͢ Event Tracker ·ͱΊ
CRS Engine 4. Joiner Event Tracker Joiner Learning worker Importer
LINE App Contents Contents Imp/Click Log Log Parameter
None
• ϢʔβʔͷContentsʹର͢ΔԠ͕Γ͍ͨ • imp͞Εͨcontents͕click͞Ε͔ͨɺmute͞Ε͔ͨ • impͱclick/muteΛjoin͍ͨ͠ Γ͍ͨ͜ͱ
• imp͕ಧ͍ͨஈ֊Ͱclickmuteະདྷͷࣄ • click͕དྷͨ࣌Ͱimpॲཧ͞Εͯ͠·͍ͬͯΔ • impΛ͋ΔఔԆͤͯ͞ॲཧ͍ͨ͠ Ͳ͏͢Εྑ͍͔
• impͷconsumeΛ10minΒͤΔ • clickmuteͦͷ··Redisʹ • 10minޙimpΛॲཧ͢Δͱ͖ʹredisΛࢀর Ԇconsumer https://www.slideshare.net/linecorp/line-ads-platformkafka-126180436
• MLͷڭࢣσʔλͷूܭॲཧ • KafkaΛԠ༻ͨ͠ԆConsumerॲཧ Joiner ·ͱΊ
CRS Engine 5. Learning worker Event Tracker Joiner Learning worker
Importer LINE App Contents Contents Imp/Click Log Log Parameter
None
• engine͕rankerɺ͜͜trainerଆ • σʔλྔ͕ଟ͍ͷͰฒྻԽ͍ͨ͠ • ޮԽͷͨΊ·ͱΊͯॲཧ͍ͨ͠ • ಉ͡armͷσʔλಉ͡αʔόʔͰॲཧ Learning worker
• BanditͷTrainerPython • NginxͰ Consistent hashing • User trafficΛड͚ΔRankerjava Learning
worker
• NumPy/Numba͕͍͔ͨͬͨ • BanditΛ։ൃͯ͠Δͷdatalabs -> ML part • Ranker҆ఆੑΛॏࢹ͍ͨ͠ͷͰJavaͰؤுͬͯॻ͘ •
Python <-> JavaͷΠϯλʔϑΣʔεprotobufͰఆٛ Why Python
• Bandit algorithmsͷTrainer • ඇಉظ/ޮతʹֶश͢ΔͨΊʹ͍Ζ͍Ζͯ͠Δ • Java <-> PythonͰparameterΛड͚͠ •
͠ํֶशͷํͰ͍͔ͭ͘Λ͍ͯ͠Δ Learning worker·ͱΊ
Team
subtitle Developers • Server side engineer 5 ਓ • ML
team֤Service developerͱίϥϘϨʔγϣϯ • GlobalͷϝϯόʔͱͷΓऔΓසൟʹ͋Δ • ·ͩ·ͩ໘ന͍Spec͋ΔͷͰ͍͖͍ͬͯͨ
THANK YOU