<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jun Gu on Medium]]></title>
        <description><![CDATA[Stories by Jun Gu on Medium]]></description>
        <link>https://medium.com/@gujun720?source=rss-e0ca89fe027------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*F3jN45FPKbeXSSUKEDn9mQ.jpeg</url>
            <title>Stories by Jun Gu on Medium</title>
            <link>https://medium.com/@gujun720?source=rss-e0ca89fe027------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:44:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gujun720/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GPU Data Analytics Startups Are Gone]]></title>
            <link>https://gujun720.medium.com/gpu-data-analytics-startups-are-gone-1e5acf5a3447?source=rss-e0ca89fe027------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e5acf5a3447</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Jun Gu]]></dc:creator>
            <pubDate>Fri, 25 Mar 2022 06:28:07 GMT</pubDate>
            <atom:updated>2022-03-25T06:28:07.648Z</atom:updated>
            <content:encoded><![CDATA[<h4>Imagine GPU is an F1 car, the straights on which GPU could fully accelerate are too short.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DC2kqD-QEwIlKUENm4nZ4g.jpeg" /></figure><h3>Put on the GPU tag</h3><p>In the past decade, GPU has become an essential component in the system stack of modern data analytics, data science, machine learning, etc. Along with the vision (or slogan) of “General Purpose GPU” (GPGPU), building up a software company upon GPU looked promising.</p><p>Our startup was founded in May 2017. Yes, it was positioned as a GPU software company. At that time, we called ourselves “Reinvent Data Science”. Part of the reason was, like many startups, we didn’t know what exactly we would build with GPU later. In the meantime, several software companies announced the “GPU Open Analytics Initiative” (GOAI)[1].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FMTd-WS2YCoFDLRQ.png" /></figure><p>Although people had started to use GPU in training deep learning models and mining cryptocurrency since 2010, that was more for academic research or blockchain. In 2017, PyGDF[2] and GPU databases[3] were the hottest GPU analytics technologies in business analytics (or big data). And GOAI covered both of them. I thought GOAI was a mark of GPU arising in the business analytics scenarios. Honestly, I was worried about us not being part of that initiative for a long time.</p><p>MapD was the pioneer of GPU databases and probably still the technology leader. MapD inspired many teams. Our first attempt was also a GPU database with distributed scalability (according to our initial plan). But soon, the team was caught in a big challenge of database fundamentals. It is well described in the first comment of this Hacker News thread[3].</p><blockquote><em>Most traditional SQL databases are I/O-bound, meaning that the cost of pulling index pages from disk into memory overwhelms everything else, and adding more CPU doesn’t do much good.</em></blockquote><p>When vendors talk about GPGPU, it does not mean GPU could serve general requirements. It only means GPU is more than graphics, and it could help other computation-intensive workloads as well. However, most big data scenarios are I/O sensitive, which means either it’s I/O-intensive or spending the most time on data transmission across different nodes in the network. Imagine GPU is an F1 car, the straights on which GPU could fully accelerate are too short.</p><p>I was not sure if there were compelling reasons for users to adopt GPU in a data system. The fanciest applications of GPU databases were spatial and temporal data analysis and geo-visualization powered by server-side GPU rendering. Remember it was 2018; 5 G/IoT/cloud gaming were hot topics. So server-side GPU rendering seemed pretty cool. We made a prototype without much technical challenge. Then the new problem was who had the spatial and temporal data, and they were eager to analyze the data. Few users we could find, and all of them are either big companies or government-authorized companies in the GIS industry. We, a small startup, have no way to build a scalable business by serving them.</p><p>In later 2018, Nvidia announced the RAPIDS project[4]. RAPIDS was an upgrade and replacement of GOAI. I guess Nvidia wanted another win like CUDA[5].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RQyNGkWZtWiqBe1K.png" /></figure><p>I thought GPU software companies would be even hard then.</p><h3>Remove the GPU tag</h3><p>During a demo case, users asked us if they could store arrays into the GPU database. The arrays are actually the embeddings generated from machine learning models. After some research, our intuition told us this new type of data deserved serious treatment.</p><p>Thus we modified our product to focus on embeddings. And we finally found a solid GPU use case, building the ANN indexes for embeddings. While creating the indexes, the embeddings will be transferred into the GPU memory, so there is much less I/O overhead, and GPU could achieve 4X ~ 5X faster than CPU. (It is still less than 10X.) Moreover, we designed a hybrid index. The similarity search will be run on both CPU and GPU using the hybrid index.</p><p>We received positive feedback about our work. But most user inquiries were, “Could I run this project without GPU?”. We created something people want to use, and it’s not about GPU. We were relieved from GPU, great. At the end of 2019, we removed the GPU dependency from our project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k58CpE5MOzl8Nim_.png" /><figcaption>Milvus 0.6.0 release note</figcaption></figure><h3>The end</h3><p>After that, I still regularly checked the status of the GPU software ecosystem. I am curious if someone could figure out the way of GPU software companies. Some of my observations:</p><ul><li><a href="https://databricks.com/session_na20/deep-dive-into-gpu-support-in-apache-spark-3-x">Spark 3.x started to support GPU 2020</a></li><li>People from the GPU software ecosystem founded a new startup: <a href="https://voltrondata.com/news/joining-forces-for-an-arrow-native-future/">Voltron Data: Joining Forces for an Arrow-Native Future 2021</a>. GPU was not highlighted.</li><li>MapD has rebranded twice. And GPU is no longer mentioned: <a href="https://www.heavy.ai/blog/mapd-has-rebranded-to-omnisci">MapD has rebranded to OmniSci 2018</a>, <a href="https://www.heavy.ai/news/omnisci-announces-rebrand-to-heavy-ai-to-mark-a-new-era-of-advanced-analytics-for-time-sensitive-decision-making-at-enterprise-scale">OmniSci Announces Rebrand to HEAVY.AI 2022</a></li><li>Nvidia failed to acquire Arm at last: <a href="https://nvidianews.nvidia.com/news/nvidia-and-softbank-group-announce-termination-of-nvidias-acquisition-of-arm-limited">NVIDIA and SoftBank Group Announce Termination of NVIDIA’s Acquisition of Arm Limited 2022</a></li><li>So far, there are <a href="https://github.com/rapidsai">70+ RAPIDS repos on GitHub</a>. I have the feeling that RAPIDS is a massive demo. You can build many things with it as long as you spend lots of effort.</li></ul><h3>Reference</h3><ol><li><a href="https://www.anaconda.com/blog/data-science-and-deep-learning-application-leaders-form-gpu-open-analytics-initiative">GOAI announcement Data Science And Deep Learning Application Leaders Form GPU Open Analytics Initiative 2017</a></li><li><a href="https://www.anaconda.com/blog/getting-started-with-gpu-computing-in-anaconda">Getting Started with GPU Computing in Anaconda 2017</a></li><li><a href="https://news.ycombinator.com/item?id=14291321">Hacker News thread: MapD Open Sources GPU-Powered Database 2017</a></li><li><a href="https://nvidianews.nvidia.com/news/nvidia-introduces-rapids-open-source-gpu-acceleration-platform-for-large-scale-data-analytics-and-machine-learning">NVIDIA Introduces RAPIDS Open-Source GPU-Acceleration Platform for Large-Scale Data Analytics and Machine Learning 2018</a></li><li><a href="https://en.wikipedia.org/wiki/CUDA">Wikipedia: CUDA</a></li><li><a href="https://www.sciencedirect.com/science/article/abs/pii/S0031320304000524?via%3Dihub">Paper in Pattern Recognition: GPU implementation of neural networks 2004</a></li><li><a href="https://www.quora.com/Who-introduced-GPU-to-deep-learning">Who introduced GPU to deep learning?</a></li><li><a href="https://genesisblockhk.com/the-history-and-future-of-bitcoin-mining/">The History and Future of Bitcoin Mining</a></li><li><a href="https://en.wikipedia.org/wiki/OpenCL">Wikipedia: OpenCL</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e5acf5a3447" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Exclusive License to Make Money From the Community Contributions]]></title>
            <link>https://gujun720.medium.com/the-exclusive-license-to-make-money-from-the-community-contributions-b2eef7f5b009?source=rss-e0ca89fe027------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2eef7f5b009</guid>
            <category><![CDATA[license]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Jun Gu]]></dc:creator>
            <pubDate>Thu, 03 Feb 2022 08:52:05 GMT</pubDate>
            <atom:updated>2022-02-03T08:52:05.478Z</atom:updated>
            <content:encoded><![CDATA[<h4>Are open-source companies claiming too much from their contributors?</h4><h3>Open source is hot</h3><p>The investment in open source software (OSS) is the hottest in the past decade. Although the number of fundraising events didn’t increase, the money raised has more than tripled in 2021.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/0*omi1r2sPlS-Y_MC4.png" /><figcaption>Money raised by OSS companies</figcaption></figure><p><strong>Notes:</strong></p><ol><li>Data collected from Crunchbase with ‘open source’ as the organization industries.</li><li>Not all companies disclosed the money raised in the fundraising events.</li><li>The data for 2021 is between Jan. 1st to Dec. 21st.</li></ol><p>Besides the money raised, there have been more unicorn companies and well-known IPO events in the OSS world in 2021. Overall, these are positive signals to the so-called OSS industry. More investment and success stories could improve the sustainability of OSS projects. It inspires more people to join the open-source world as contributors or startup founders.</p><p>But more money and more attention also bring new issues to the OSS world. Since the potential valuation of OSS projects goes high, taking the leadership of good OSS projects is a profitable action. In some cases, there is intense competition on the contributions to OSS projects, for example, Kubernetes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*MunOyY9x-Jz3ckwl.png" /></figure><p>This is still a benign competition. But we could also find some tricky cases about how the OSS project owners try to control the community contributors.</p><h3>The “exclusion” in OSS contribution</h3><p>The below statements are extracted from the SEC Form S-1 when a particular open-source company submitted the IPO registration materials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jhUQhtPFKK6DcZ5F.png" /></figure><p>Why did I mask the company name?</p><p>I am not going to criticize any particular company in this article. Because what they do is to follow the “industrial standard practice” at this moment. We should discuss if the “industrial standard practice” is reasonable rather than the right or wrong of some companies.</p><p>The exclusive license they mentioned here is upsetting. When contributing to an open-source project, people’s mindset would be open, share, give back, etc. Exclusive is never part of those senses of morals. How come a company is exclusively controlling my work?</p><p>The magic behind it is how the company makes up the contributing process.</p><p>Before making any contributions, people need to sign a contributor license agreement (CLA). This is copied from Apache Software Foundation (ASF) practice. However, the company usually removes the below commitment from the ASF CLA document.</p><blockquote><em>In return, the Foundation shall not use Your Contributions in a way that is contrary to the public benefit or inconsistent with its nonprofit status and bylaws in effect at the time of the Contribution.</em></blockquote><p>So their CLA is not bi-direction. It’s just the contributors are making a commitment, delegation to the company. You should be aware that you are signing the CLA with the company, not the OSS community. The company is the initiator of the OSS community, but is it the community?</p><p>Since the contributors only sign the CLA with the company in the process. So the company could claim it has the exclusive license to make money from the community contributions.</p><p>Is it what the community expects?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2eef7f5b009" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Way to the Cloud-scalable Vector Database]]></title>
            <link>https://gujun720.medium.com/way-to-the-cloud-scalable-vector-database-49c590f73196?source=rss-e0ca89fe027------2</link>
            <guid isPermaLink="false">https://medium.com/p/49c590f73196</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[vector-database]]></category>
            <dc:creator><![CDATA[Jun Gu]]></dc:creator>
            <pubDate>Fri, 17 Dec 2021 08:57:27 GMT</pubDate>
            <atom:updated>2021-12-21T01:11:58.262Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>How we designed the </em><a href="https://milvus.io/"><em>Milvus vector database</em></a><em> 2.0</em></h4><h3>Objectives of Milvus vector database</h3><p>When the idea of the <a href="https://milvus.io/">Milvus vector database</a> first came to our minds, we wanted to build a data infrastructure that could help people accelerate AI adoptions in their organizations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WEisF1VZXQG5cyIY.png" /><figcaption><strong>How Milvus fit into the AI/ML applications</strong></figcaption></figure><p>We have set two crucial objectives for the Milvus project to fulfill this mission.</p><h4>Ease of use</h4><p>AI/ML is an emerging area where new technologies keep coming out. Most developers are not entirely familiar with the fast-growing technologies and tools of AI. Developers have already consumed most of their energies finding, training, and tuning the models. It’s hard for them to spend additional efforts handling the large amounts of embedding vectors generated by the models. Not to mention the manipulation of a large volume of data is always a very challenging task.</p><p>Thus we give “ease of use” a very high priority since it could significantly reduce the development cost.</p><h4>Low running costs</h4><p>One of the primary hurdles of AI in production is to justify the return of investment. We would have more opportunities to put our AI applications into production with lower running costs. And it would be conducive to lifting the margin of potential benefits.</p><h4>Design principles of Milvus 2.0</h4><p>We made a start towards these goals in Milvus 1.0. But it’s far from enough, especially in scalability and availability. Then we started the development of Milvus 2.0 to improve these points. The principles we have laid down for this new version include:</p><ul><li>Aiming for high scalability and availability</li><li>Building upon mature cloud infrastructure and practice</li><li>Minimum performance compromise in the cloud</li></ul><p>In other words, we want to make the Milvus database cluster cloud-native.</p><h3>The evolution of database clusters</h3><p>The vector database is a new species of database, as it handles new types of data (vectors). But it still shares the same challenges as other databases, with some of its own requirements. In the rest of this article, I will focus on what we have learned from the existing database cluster implementations and the thinking process of how we designed the new Milvus group architecture.</p><p>If you are interested in the implementation details of Milvus group components, please stay on top of the Milvus documentation. We will continuously publish technical articles in the Milvus GitHub repo, Milvus website, and Milvus Blog.</p><h4>The ideal database cluster</h4><blockquote>“Aim small, miss small.”</blockquote><p>Let’s first list the critical capabilities an ideal database cluster should have.</p><ol><li>Concurrency and no single point of failure: users connected to different group members can simultaneously have read/write access to the same piece of data.</li><li>Consistency: different group members should see the same data.</li><li>Scalability: we can add or remove group members on the go.</li></ol><p>Honestly, all of these capabilities are hard to acquire together. In the modern implementations of database clusters, people have to compromise some of these capabilities. People don’t expect a perfect database cluster as long as it can fit into the user scenarios. However, the shared-everything cluster was once very close to an ideal database cluster. If we want to learn something, we should start from here.</p><h4>The key considerations of a database cluster</h4><p>The shared-everything cluster has a more extended history compared to other modern implementations. Db2 data sharing group and Oracle RAC are typical of shared-everything clusters. Many people think shared-everything means sharing disks. It’s far more than that.</p><p>A shared-everything cluster only has one kind of database member in the group. Users could connect to any one of these symmetric members to access any data. What is “everything” that needs to be shared for making this work?</p><p><strong>The sequence of events in the group</strong></p><p>First, the group event sequence is crucial to resolve the potential conflicts caused by the concurrent access from different groups members. We usually use the database log record sequence number to represent the event sequence. At the same time, the log record sequence number is generally generated from the timestamp.</p><p>Thus the requirement of group event sequence is equal to the need of a global timer. If we could have an atomic clock for the group, that would be fabulous. Yet, Milvus is an open-source software project, which means we should rely on commonly available resources. To date, an atomic clock is still a premium option for large companies.</p><p>We have implemented the time synchronization component in Milvus 2.0 database cluster. You can find the link in the appendix.</p><p><strong>Global locking</strong></p><p>The database has a locking mechanism to resolve concurrent access conflicts, whether optimistic or pessimistic locks. Similarly, we need global locking to resolve simultaneous access conflicts across different group members.</p><p>Global locking means different group members have to talk with each other to negotiate the lock requests. Several vital factors would impact the efficiency of this global lock negotiation process:</p><ul><li>The speed of inter-system connections</li><li>The number of group members who need to participate in the negotiation process</li><li>The frequency of group conflicts</li></ul><p>The typical group size is no more than 100. For example, Db2 DSG is 32; Oracle RAC is 100. Those group members will be placed in one server room connected with optical fiber to minimize transfer latency. That’s why it is sometimes called a centralized cluster. Due to the group size limitation, people will choose high-end servers (mainframes or minicomputers, which have much more capacity in CPU, memory, I/O channels, etc.) to consist of the shared-everything clusters.</p><p>This hardware presumption has dramatically changed in the modern cloud environment. Nowadays, cloud data centers comprise high-dense server rooms full of (thousands of) commodity X86 servers with TCP/IP connections. If we rely on these X86 servers to build the database cluster, the group size should increase to hundreds of (even thousands of) machines. And in some business scenarios, we will want these hundreds of X86 machines to spread in different regions. Thus implementing global locking might not be worth it anymore, as the global locking performance will not be good enough.</p><p>In Milvus 2.0, we are not going to implement the global locking facility. On the one hand, there is no update for vector data. (People should rather delete-then-insert instead of update.) So we don’t need to worry about the multi-writer conflicts on the same piece of data in the Milvus group with sharding arrangement. Meantime, we could use MVCC (multi-version concurrency control, a lock-avoidance concurrency control method) to resolve the reader-writer conflicts.</p><p>On the other hand, vector data processing consumes a much higher memory footprint than structured data processing. People are looking for much higher scalability in vector databases.</p><p><strong>Shared in-memory data cache</strong></p><p>We can briefly divide a database engine into two parts: the storage engine and the computing engine. The storage engine is responsible for two critical tasks:</p><ul><li>Write data to permanent storage for durability purposes.</li><li>Load data from the permanent storage to the in-memory data cache (AKA buffer pool); this is the only place where the computing engine accesses data.</li></ul><p>In the database cluster scenario, what if member A has updated the data cached in member B? How could member B know its in-memory data is expired? The classic shared-everything cluster has a buffer cross invalidation mechanism to resolve this issue. The buffer cross invalidation mechanism will work similarly to global locking if we maintain a strong consistency across the group members. As stated before, it is not practical in the modern cloud environment. So we decided to lower the consistency level in the Milvus cloud-scalable group to an eventual consistency manner. In this way, the buffer cross invalidation mechanism in Milvus 2.0 can be an asynchronous process.</p><p><strong>Shared storage</strong></p><p>Shared storage is probably the first thing people would think about when discussing a database cluster.</p><p>Storage options have also significantly changed in recent years of cloud storage evolution. The storage attached network (SAN) was (and still is) the storage foundation of the shared-everything group. But in the cloud environment, there is no SAN. The database has to use the local disk attached to the cloud virtual machines. Using local disk introduces the challenge of data consistency across the group members. And we also have to worry about the high availability of the group members.</p><p>Then Snowflake made a great role model for cloud databases using cloud shared storage (S3 storage). It inspires Milvus 2.0 too. As stated before, we intend to rely on mature cloud infrastructure. But before we could utilize cloud shared storage, we have to think about a couple of things.</p><p>First, S3 storage is cheap and reliable, but it is not designed for instant R/W access like database scenarios. We need to create the data components (which we call data nodes in Milvus 2.0) to bridge the local memory/disk and S3 storage. There are some examples (like Alluxio, JuiceFS, etc.) we could learn. The reason we can not integrate these projects directly is we focus on different data granularity. Alluxio and JuiceFS are designed for datasets or POSIX files, while we focus on the data record (vector) level.</p><p>When the vector data is settled on S3 storage, the answer for metadata is easy: store them in ETCD. How about the log data, then? In the classic implementations, the log store is also based on SAN. The log files of one database group member are shared within the database cluster for failure recovery purposes. So this was not a problem until we got into the cloud environment.</p><p>In the Spanner paper, Google illustrated how they implemented the globally-distributed database (group) with Paxos consensus algorithm. You need to program the database cluster as a state machine replication group. The redo log is usually the “state” that will be replicated across the group.</p><p>Redo-log replication by consensus algorithms is a powerful tool, and it has substantial advantages in some business scenarios. But for the Milvus vector database, we don’t find enough incentives for creating a state machine replication group as a whole. We decided to use the cloud messaging queue/platform (Apache Pulsar, Apache Kafka, etc.) as an alternative cloud shared storage for the log store. By delegating the log store to the messaging platform, we acquire the benefits below.</p><ul><li>The group is more event-driven, which means many processes can be asynchronous. It improves scalability.</li><li>The components are more loosely coupled, making it much easier to perform online rolling upgrades. It improves availability and operability.</li></ul><p>We will revisit this topic in the later section.</p><p>So far, we have wrapped up the crucial considerations of the database cluster. Before we can jump to the discussion on the Milvus 2.0 architecture, let me first explain how we manage vectors in Milvus.</p><h4>Data management and performance predictability</h4><p>Milvus stores vectors in collections. The “collection” is a logical concept, equivalent to a “table” in SQL databases. A “collection” could have multiple physical files to keep vectors. A physical file is a “segment”. The “segment” is a physical concept like a tablespace file in SQL databases. When the data volume is small, we can save everything in a single segment/physical file. But nowadays, we are constantly facing big data. When there are multiple segments/physical files, how should we spread the data in different data partitions?</p><p>Although data comes first rather than indexes, we have to store data in the way that the index algorithm prefers to make the data access efficiently in most cases. A frequently used strategy in SQL databases is partition by the range of partitioning key values. People usually create a clustered index to enforce the partitioning key. Overall, this is a decent approach for SQL databases. Data is stored in good shape, optimized for I/O (prefetch). But there are still defects.</p><ul><li>Data skew. Some of the partitions might have much more data than others. The distribution of real-world data is not as simple as the numeric range.</li><li>Access hotspots. More workload might go to some of the data partitions.</li></ul><p>Imagine more workload goes to partitions with more data. We need to rebalance the data across the partitions when these situations occur. (This is a DBA’s tedious daily life.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZHxxeOsHzMRWq06N.png" /><figcaption><strong>The clustered index for vectors</strong></figcaption></figure><p>We can also create a clustered index for vectors (an inverted list index). But that is not the same case as SQL databases. Once the index is built in SQL databases, it’s very efficient to access the data through the index, with less computation and less I/O operations. But for vector data, there will be far more computation and I/O operations even with an index. So the defects mentioned before will have a more severe impact on vector database clusters. Moreover, the cost of rebalancing vectors across different segments is very high due to the data volume and computing complexity.</p><p>In Milvus, we use the strategy of partition by growth. When we inject data into a vector collection, Milvus will append the new vectors to the latest segment in the collection. Milvus will close the segment once its size is large enough (the threshold is configurable) and build the index for the closed segment. In the meantime, a new segment will be created to store the upcoming data. This simple strategy is more balanced for vector processing.</p><p>The vector query is a process to search for the most similar candidates in the vector collection. It is a typical MapReduce procedure. For example, we want to search the top 20 similar results from a vector collection with ten segments. We can search the top 20 on each one of the segments and then merge the 20 * 10 results into the final 20 results. Since each segment has the same amount of vectors and a similar index, the processing time on each segment is almost identical. It gives us the advantage of performance predictability, which is essential when planning the scale of the database clusters.</p><h4>New paradigms in Milvus 2.0</h4><p>In Milvus 1.0, we implemented a read/write splitting sharding group like most SQL databases. It was a good attempt at scaling the Milvus database cluster. But the problems are quite obvious too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VGvr75MowHBu-Zlu.png" /><figcaption><strong>Milvus 1.0: sharding cluster</strong></figcaption></figure><p>In Milvus 1.0, the R/W node has to take total care of the latest segment, including vector appending, searching in this unindexed segment, building index, etc. Since each collection only has one writer, the writer is very busy if the data is continuously streamed into the system. The performance of data sharing between the R/W node and the reader nodes is also a problem. Besides, we must either rely on NFS (not stable) or premium cloud storage (too expensive) for shared data storage.</p><p>These existing problems are hard to tackle in the Milvus 1.0 architecture. Thus, we have introduced new paradigms into the Milvus 2.0 design to resolve these issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Szns525xrCyvE7Sg.jpeg" /><figcaption><strong>Milvus 2.0: cloud-scalable vector database</strong></figcaption></figure><p><strong>Actor model</strong></p><p>There are two models to program concurrent computation systems.</p><ul><li>Shared memory that means concurrency control (locking) and synchronous processing</li><li>The actor model (AKA message passing) means message-driven and asynchronous processing</li></ul><p>We can also apply these two models in distributed database clusters.</p><p>As stated before, most high-profile distributed databases use the same method: redo-log replication by consensus algorithms. This is synchronous processing using consensus algorithms to build a distributed shared memory for redo-log records. Different companies and venture capitals have invested billions of bucks in this technology. I didn’t want to comment on this until we started to work on Milvus 2.0. Many people regard this technology as the only way to realize distributed database systems. This is annoying. If I don’t say something, people might misunderstand that we were reckless in distributed database design.</p><p>In recent years, Redo-log replication by consensus algorithms has been the most overestimated database technology. There are two key issues.</p><ul><li>The presumption that redo-log replication is better is fragile.</li><li>Vendors mislead people’s expectations on the capability of consensus algorithms.</li></ul><p>Let’s say we have two database nodes, the source node, and the target node. In the ever beginning, they have the exact copy of the data. We have some change operations (I/U/D SQL statements) on the source node, and we want to keep the target node updated. What should we do? The simplest way is to replay the operations on the target node. But this is not the most efficient way.</p><p>Thinking about the running cost of an I/U/D statement, we can divide it into the execution preparation and the physical work parts. The execution preparation part includes the work of SQL parser, SQL optimizer, etc. No matter how many data records will be affected, it is a fixed cost. The cost of the physical work part depends on how many data records will be affected; it is a floating cost. The idea behind redo-log replication is to save the fixed cost on the target node; we only replay the redo-log (the physical work) on the target node.</p><p>The cost-saving percentage is the reciprocal of the number of redo-log records. If one operation only affects one record, I should see significant savings from redo-log replication. What if it’s 10,000 records? Then we should worry about the network reliability. Which one is more reliable, send the one operation or the 10,000 redo-log records? How about one million records? Redo-log replication is super in scenarios like payment systems, metadata systems, etc. In these scenarios, each database I/U/D operation only affects a small number of records (1 or 2). But it’s hard to work with I/O intensive workloads like batch jobs.</p><p>Vendors always claim consensus algorithms could provide strong consistency to the database clusters. But people only use consensus algorithms to replicate the redo-log records. The redo-log records are consistent on different nodes, but that doesn’t mean the data views on other nodes are consistent either. We have to merge the redo-log records into the actual table records. So even with this synchronous processing, we can still only get eventual consistency on the data views.</p><p>We should use redo-log replication by consensus algorithms in the appropriate places. The metadata system (ETCD) and messaging platform (e.g., Apache Pulsar) used in Milvus 2.0 have implemented consensus algorithms. But as I said before, “for the Milvus vector database, we don’t find enough incentives for being a state machine replication group as a whole.”</p><p>In Milvus 2.0, we use the actor model to organize the worker nodes. The worker nodes are lonely. They only talk to the messaging platform, getting commands and sending results. It sounds boring.</p><blockquote><em>“What is our motto?” <br>“Boring is always best.”<br> — The Hitman’s Bodyguard (2017)</em></blockquote><p>The actor model is asynchronous. It is suitable for scalability and availability. Since the worker nodes don’t know each other, there is no impact on other worker nodes if some of the worker nodes join or are removed.</p><p><strong>Separation of availability and durability</strong></p><p>In Milvus 2.0, we do operation replay rather than log replay, because in the vector database, there is not much difference between operation replay and log replay. We don’t have the Update function nor the Insert with Select function. And it’s also much easier to do operation replay with the actor model.</p><p>So multiple worker nodes might execute the same operation from the messaging platform according to their responsibility. I mentioned before we decided to use the S3 cloud storage as the shared storage layer of the Milvus database cluster. The S3 storage is very reliable. Then is it necessary for different worker nodes to write out the same data to the shared storage?</p><p>Thus we designed three roles for the worker nodes.</p><ul><li>The query node maintains an in-memory data view according to the assignment. The work of the query node includes doing vector search and keeping the in-memory data updated. But it doesn’t need to write anything to the S3 storage. It is the most memory-sensitive node in the group.</li><li>The data node is responsible for writing the new data to the S3 storage. The data node doesn’t need to maintain the in-memory data view, so the hardware configuration of the data node is quite different from the query node.</li><li>The index node builds indexes for the segments closed by the data node when the size of the segments reaches the threshold. This is the most CPU-intensive work in the group.</li></ul><p>These three types of nodes represent different kinds of workload. They can scale independently. We call it separation of availability and durability learned from the Microsoft Socrates cloud database.</p><h3>The end, also the beginning</h3><p>This article has reviewed several design decisions of Milvus vector database 2.0. Let’s quickly wrap up those points here.</p><ul><li>We have chosen the eventual consistency for Milvus cluster 2.0.</li><li>We have integrated the mature cloud components into Milvus 2.0 as much as we can. We have controlled the new components introduced by Milvus 2.0 into users’ production environments.</li><li>By following the actor model and separation of availability and durability, Milvus 2.0 is easy to scale in the cloud environment.</li></ul><p>So far, we have formed the backbone of the Milvus 2.0 cloud-scalable database, but our backlog contains many requirements from the Milvus community that need to be satisfied. If you have the same mission (“Build more open-source infrastructure software to accelerate the AI transformation”), welcome to join the Milvus community.</p><p>Milvus is a graduation project of the LF AI &amp; Data foundation. You do NOT need to sign any CLA for Milvus!</p><h3>Appendix</h3><h4>Milvus resources</h4><ul><li><a href="https://milvus.io/">Milvus website</a></li><li><a href="https://discuss.milvus.io/">Milvus Disccuss forum</a></li><li><a href="https://slack.milvus.io/">Milvus Slack channel</a></li><li><a href="https://github.com/milvus-io/milvus/tree/master/docs/design_docs">Milvus design doc</a></li><li><a href="https://github.com/milvus-io/milvus/blob/master/docs/design_docs/milvus_timesync_en.md">Milvus Time Synchronization</a></li></ul><h4>Other interesting stuff you may want to check</h4><p><strong>Raft implementation in C++</strong></p><p>If you are still interested in the consensus algorithm, I suggest you check <a href="https://github.com/eBay/Gringofts">eBay’s open-source project Gringofts</a>. It’s a C++ implementation of the Raft consensus algorithm (a variant of the Paxos family). My friend Jacky and Elvis (my ex-colleagues at Morgan Stanley) built it for the eBay online payment system, which is precisely one of the most suitable scenarios for this technology.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49c590f73196" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making with Milvus: AI-Powered News Recommendation Inside Xiaomi’s Mobile Browser]]></title>
            <link>https://medium.com/data-science/making-with-milvus-ai-powered-news-recommendation-inside-xiaomis-mobile-browser-18e41d112c5f?source=rss-e0ca89fe027------2</link>
            <guid isPermaLink="false">https://medium.com/p/18e41d112c5f</guid>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[bert]]></category>
            <category><![CDATA[news]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Jun Gu]]></dc:creator>
            <pubDate>Mon, 08 Mar 2021 12:05:43 GMT</pubDate>
            <atom:updated>2021-03-09T13:54:15.112Z</atom:updated>
            <content:encoded><![CDATA[<h4>Discover how Xiaomi leveraged AI and Milvus to build an intelligent news recommendation system capable of finding the most relevant content for users of its mobile web browser</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nVVg8m4yHYJHo0Ew" /><figcaption>Photo by <a href="https://unsplash.com/@priscilladupreez?utm_source=medium&amp;utm_medium=referral">Priscilla Du Preez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>From social media feeds to playlist recommendations on Spotify, <a href="https://zilliz.com/blogs/Vector-Similarity-Search-Hides-in-Plain-View">artificial intelligence</a> already plays a major role in the content we see and interact with each day. In an effort to differentiate their mobile web browser, multinational electronics manufacturer Xiaomi built an AI-powered news recommendation engine. <a href="https://milvus.io/">Milvus</a>, an open-source vector database built specifically for similarity search and artificial intelligence, was used as the application’s core data management platform. This article explains how Xiaomi built its AI-powered news recommendation engine, and how Milvus and other AI algorithms were used.</p><h3>Using AI to suggest personalized content and cut through news noise</h3><p>With the New York Times alone publishing over <a href="https://www.theatlantic.com/technology/archive/2016/05/how-many-stories-do-newspapers-publish-per-day/483845/">230 pieces</a> of content each day, the sheer volume of articles produced makes it impossible for individuals to get a comprehensive view of all the news. To help sift through large volumes of content, and recommend the most relevant or interesting pieces, we increasingly turn to AI. Although recommendations remain far from perfect, machine learning is increasingly necessary to cut through the constant stream of new information pouring out of our increasingly complex and interconnected world.</p><p>Xiaomi makes and invests in smartphones, mobile apps, laptops, home appliances, and many more products. In an effort to differentiate a mobile browser that comes preinstalled on many of 40+ million smartphones the company sells each quarter, Xiaomi built a news recommendation system into it. When users launch Xiaomi’s mobile browser, artificial intelligence is used to recommend similar content based on user search history, interests, and more. Milvus is an open-source vector similarity search database used to accelerate retrieval of related articles.</p><h3>How does AI-powered content recommendation work?</h3><p>At its core, news recommendation (or any other type of content recommendation system) involves comparing input data to a massive database to find similar information. Successful content recommendation involves balancing relevance with timeliness, and efficiently incorporating huge volumes of new data — often in real time.</p><p>To accommodate massive datasets, recommendation systems are typically divided into two stages:</p><ol><li><strong>Retrieval:</strong> During retrieval, content is narrowed down from the broader library based on user interests and behavior. In Xiaomi’s mobile browser, thousands of pieces of content are selected from a massive dataset that contains millions of news articles.</li><li><strong>Sorting:</strong> Next, content selected during retrieval is sorted according to certain indicators before being pushed to the user. As users engage with recommended content, the system adapts in real time to provide more relevant suggestions.</li></ol><p>News content recommendations need to be made in real-time based on user behavior and recently published content. Additionally, suggested content must match user interests and search intent as much as possible.</p><h3>Milvus + BERT = intelligent content suggestions</h3><p>Milvus is an open-source vector similarity search database that can be integrated with deep learning models to power applications spanning natural language processing, identity verification, and much more. Milvus indexes large vector datasets to make search more efficient, and supports a variety of popular AI frameworks to simplify the process of developing machine learning applications. These characteristics make the platform ideal for storing and querying vector data, a critical component of many machine learning applications.</p><p>Xiaomi selected Milvus to manage vector data for its intelligent news recommendation system because it is fast, reliable, and requires minimal configuration and maintenance. However, Milvus must be paired with an AI algorithm to build deployable applications. Xiaomi selected BERT, short for Bidirectional Encoder Representation Transformers, as the language representation model in its recommendation engine. BERT can be used as a general NLU (natural language understanding) model that can drive a number of different NLP (natural language processing) tasks. Its key features include:</p><ul><li>BERT’s transformer is used as the main framework of the algorithm and is capable of capturing explicit and implicit relationships within and between sentences.</li><li>Multi-task learning goals, masked language modeling (MLM), and next sentence prediction (NSP).</li><li>BERT performs better with greater amounts of data, and can enhance other natural language processing techniques such as Word2Vec by acting as a conversion matrix.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*ci_-bOBWRQS5Bv5Z" /><figcaption><em>Milvus working with BERT. Image by author.</em></figcaption></figure><p>BERT’s network architecture uses a multi-layer transformer structure that abandons the traditional RNN and CNN neural networks. It works by converting the distance between two words at any position into one through its attention mechanism, and solves the dependency issue that has persisted in NLP for some time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*u5Mf4pA8ToBMlWLc" /><figcaption><em>A transformer’s network architecture in BERT. Image by author.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*SZhvYymtD-rLQGRy" /><figcaption><em>BERT’s network structure. ‘Trm’ represents the transformer network architecture depicted above. Image by author.</em></figcaption></figure><p>BERT provides a simple and a complex model. The corresponding hyperparameters are as follows: BERT BASE: L = 12, H = 768, A = 12, total parameter 110M; BERT LARGE: L = 24, H = 1024, A = 16, the total number of parameters is 340M.</p><p>In the above hyperparameters, L represents the number of layers in the network (i.e. the number of Transformer blocks), A represents the number of self-Attention in Multi-Head Attention, and the filter size is 4H.</p><h3>Xiaomi’s content recommendation system</h3><p>Xiaomi browser-based news recommender system relies on three key components: vectorization, ID mapping, and approximate nearest neighbor (ANN) service.</p><p>Vectorization is a process where article titles are converted into general sentence vectors. The SimBert model, based on BERT, is used in Xiaomi’s recommendation system. SimBert is a 12-layer model with a hidden size of 768. Simbert uses the training model Chinese L-12_H-768_A-12 for continuous training (training task being “metric learning +UniLM”, and has trained 1.17 million steps on a single TITAN RTX with the Adam optimizer (learning rate 2e-6, batch size 128). Simply put, this is an optimized BERT model.</p><p>ANN algorithms compare vectorized article titles to the entire news library stored in Milvus, then return similar content for users. ID mapping is used to obtain relevant information such as page views and clicks for corresponding articles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*JX1J2aMhNWXoq4MO" /><figcaption><em>How content recommendation works. Image by author.</em></figcaption></figure><p>The data stored in Milvus that powers Xiaomi’s news recommendation engine is constantly being updated, including additional articles and activity information. As the system incorporates new data, old data must be purged. In this system, full data updates are done for the first T-1 days and incremental updates are done in the subsequent T days.</p><p>At defined intervals, old data is deleted and processed data of the T-1 days is inserted into the collection. Here newly generated data is incorporated in real time. Once new data is inserted, similarity search is conducted in Milvus. Retrieved articles are again sorted by click rate and other factors, and the top content is shown to users. In a scenario like this where data is frequently updated and results must be delivered in real time, Milvus’ ability to rapidly incorporate and search new data makes it possible to drastically accelerate news content recommendation in Xiaomi’s mobile browser.</p><h3>Milvus makes vector similarity search better</h3><p>Vectorizing data and then calculating similarity between vectors is the most commonly used retrieval technology. The rise of ANN-based vector similarity search engines has greatly improved the efficiency of vector similarity calculations. Compared with similar solutions, Milvus offers optimized data storage, abundant SDKs, and a distributed version that greatly reduces the workload of building a retrieval layer. Additionally, Milvus’ active open-source community is a powerful resource that can help answer questions and troubleshoot problems as they arise.</p><p>If you would like to learn more about vector similarity search and Milvus, check out the following resources:</p><ul><li>Check out <a href="https://github.com/milvus-io/milvus">Milvus</a> on Github.</li><li><a href="https://zilliz.com/blogs/Vector-Similarity-Search-Hides-in-Plain-View">Vector Similarity Search Hides in Plain View</a></li><li><a href="https://zilliz.com/blogs/Accelerating-Similarity-Search-on-Really-Big-Data-with-Vector-Indexing">Accelerating Similarity Search on Really Big Data with Vector Indexing</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18e41d112c5f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/making-with-milvus-ai-powered-news-recommendation-inside-xiaomis-mobile-browser-18e41d112c5f">Making with Milvus: AI-Powered News Recommendation Inside Xiaomi’s Mobile Browser</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Set Up Milvus in Google Colaboratory for Easy ML Application Building]]></title>
            <link>https://medium.datadriveninvestor.com/set-up-milvus-in-google-colaboratory-for-easy-ml-application-building-536dc9b75301?source=rss-e0ca89fe027------2</link>
            <guid isPermaLink="false">https://medium.com/p/536dc9b75301</guid>
            <category><![CDATA[unstructured-data]]></category>
            <category><![CDATA[milvus-project]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[google-colab]]></category>
            <dc:creator><![CDATA[Jun Gu]]></dc:creator>
            <pubDate>Wed, 23 Dec 2020 08:09:50 GMT</pubDate>
            <atom:updated>2020-12-27T16:05:24.512Z</atom:updated>
            <content:encoded><![CDATA[<h4>Google Colab makes developing and testing machine learning applications a breeze. Learn how to setup Milvus in Colab for better massive-scale vector data management</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*fpmBqX23G7GaYgQ5_5i4Yg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a> | Google Colab logo</figcaption></figure><h3>Set Up Milvus in Google Colaboratory for Easy ML Application Building</h3><p>Technological progress is perpetually making artificial intelligence (AI) and machine-scale analytics more accessible and easier to use. The <a href="https://techcrunch.com/2019/01/12/how-open-source-software-took-over-the-world/?guccounter=1&amp;guce_referrer=aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS8&amp;guce_referrer_sig=AQAAAL_qokucWT-HjbiOznq2RlO5TG78V6UYf332FKnWl3_knuMo6t5HZvZkIHFL3fhYX0nLzM6V1lVVAK4G3BXZHENX3zCXXgggGt39L9HKde3BufW1-iM2oKm0NIav2fcqgxvfpvx_7EPGstI7c_n99stI9oJf9sdsRPTQ6Wnu7DYX">proliferation</a> of open-source software, public datasets, and other free tools are primary forces driving this trend. By pairing two free resources, <a href="https://milvus.io/">Milvus</a> and <a href="https://colab.research.google.com/notebooks/intro.ipynb#scrollTo=5fCEDCU_qrC0">Google Colaboratory</a> (“Colab” for short), anyone can create powerful, flexible AI and data analytics solutions. This article provides instructions for setting up Milvus in Colab, as well as performing basic operations using the Python software development kit (SDK).</p><p><strong>Jump to:</strong></p><p>· <a href="#6a27">Set Up Milvus in Google Colaboratory for Easy ML Application Building</a><br>· <a href="#8d4c">What is Milvus?</a><br>· <a href="#63cf">What is Google Colaboratory?</a><br>· <a href="#929b">Getting started with Milvus in Google Colaboratory</a><br>· <a href="#11dc">Run basic Milvus operations in Google Colab with Python</a><br>· <a href="#33f4">Milvus and Google Colaboratory work beautifully together</a></p><h3>What is Milvus?</h3><p><a href="https://milvus.io/">Milvus</a> is an open-source vector similarity search engine that can integrate with widely adopted index libraries, including Faiss, NMSLIB, and Annoy. The platform also includes a comprehensive set of intuitive APIs. By pairing Milvus with artificial intelligence (AI) models, a wide variety of applications can be built including:</p><ul><li>Image, video, audio, and semantic text search engines.</li><li>Recommendation systems and chatbots.</li><li>New drug development, genetic screening, and other biomedical applications.</li></ul><h3>What is Google Colaboratory?</h3><p><a href="https://colab.research.google.com/notebooks/intro.ipynb#recent=true">Google Colaboratory</a> is a product from the Google Research team that allows anyone to write and run python code from a web browser. Colab was built with machine learning and data analysis applications in mind, offers a free Jupyter notebook environment, syncs with Google Drive, and gives users access to powerful cloud computing resources (including GPUs). The platform supports many popular machine learning libraries and can be integrated with PyTorch, TensorFlow, Keras, and OpenCV.</p><h3>Getting started with Milvus in Google Colaboratory</h3><p>Although Milvus recommends <a href="https://milvus.io/docs/v0.10.4/milvus_docker-cpu.md">using Docker</a> to install and start the service, the current Google Colab cloud environment does not support Docker installation. Additionally, this tutorial aims to be as accessible as possible — and not everyone uses Docker. Install and start the system by <a href="https://github.com/milvus-io/milvus/blob/0.10.4/INSTALL.md">compiling Milvus’ source code</a> to avoid using Docker.</p><h4>Download Milvus’ source code and create a new notebook in Colab</h4><p>Google Colab comes with all supporting software for Milvus preinstalled, including required compilation tools GCC, CMake, and Git and drivers CUDA and NVIDIA, simplifying the installation and setup process for Milvus. To begin, download Milvus’ source code and create a new notebook in Google Colab:</p><ol><li>Download Milvus’ source code: Milvus_tutorial.ipynb.</li></ol><pre>Wget <a href="https://raw.githubusercontent.com/milvus-io/bootcamp/0.10.0/getting_started/basics/milvus_tutorial/Milvus_tutorial.ipynb">https://raw.githubusercontent.com/milvus-io/bootcamp/0.10.0/getting_started/basics/milvus_tutorial/Milvus_tutorial.ipynb</a></pre><p>2. Upload Milvus’ source code to <a href="https://colab.research.google.com/notebooks/intro.ipynb#recent=true">Google Colab</a> and create a new notebook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*kVr6gaSMP6YhMj1Ni9nyfg.png" /></figure><h4>Compile Milvus from source code</h4><p><strong>Download Milvus source code</strong></p><pre>git clone -b 0.10.3 https://github.com/milvus-io/milvus.git</pre><p><strong>Install dependencies</strong></p><pre>% cd /content/milvus/core ./ubuntu_build_deps.sh<br>./ubuntu_build_deps.sh</pre><p><strong>Build Milvus source code</strong></p><pre>% cd /content/milvus/core<br>!ls<br>!./build.sh -t Release<br># To build GPU version, add -g option, and switch the notebook settings with GPU<br>#((Edit -&gt; Notebook settings -&gt; select GPU))<br># !./build.sh -t Release -g</pre><blockquote>Note: If the GPU version is correctly compiled, a “GPU resources ENABLED!” notice appears.</blockquote><h4>Launch Milvus server</h4><p><strong>Add lib/ directory to LD_LIBRARY_PATH:</strong></p><pre>% cd /content/milvus/core/milvus<br>! echo $LD_LIBRARY_PATH<br>import os<br>os.environ[&#39;LD_LIBRARY_PATH&#39;] +=&quot;:/content/milvus/core/milvus/lib&quot;<br>! echo $LD_LIBRARY_PATH</pre><p><strong>Start and run Milvus server in the background:</strong></p><pre>% cd scripts<br>! ls<br>! nohup ./start_server.sh &amp;</pre><p><strong>Show Milvus server status:</strong></p><pre>! ls<br>! cat nohup.out</pre><blockquote>Note: If the Milvus server is launched successfully, the following prompt appears:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*oyC7HtlfIQ9fFmRw_tYxQQ.png" /><figcaption>Milvus server started successfully!</figcaption></figure><h3>Run basic Milvus operations in Google Colab with Python</h3><p>After successfully launching in Google Colab, Milvus can provide a variety of API interfaces for Python, Java, Go, Restful, and C++. Below are instructions for using the Python interface to perform basic Milvus operations in Colab.</p><p><a href="https://www.datadriveninvestor.com/2020/08/11/being-good-at-google-is-a-skill/">Being Good at Google is a Skill | DataDrivenInvestor</a></p><p><strong>Install pymilvus:</strong></p><pre>! pip install pymilvus==0.2.14</pre><p><strong>Connect to the server</strong>:</p><pre># Connect to Milvus Server<br>milvus = Milvus(_HOST, _PORT)</pre><pre># Return the status of the Milvus server.<br>server_status = milvus.server_status(timeout=10)</pre><p><strong>Create a collection/partition/index:</strong></p><pre># Information needed to create a collection<br>param={&#39;collection_name&#39;:collection_name, &#39;dimension&#39;: _DIM, &#39;index_file_size&#39;: _INDEX_FILE_SIZE, &#39;metric_type&#39;: MetricType.L2}</pre><pre># Create a collection.<br>milvus.create_collection(param, timeout=10)</pre><pre># Create a partition for a collection.<br>milvus.create_partition(collection_name=collection_name, partition_tag=partition_tag, timeout=10)    <br>ivf_param = {&#39;nlist&#39;: 16384}</pre><pre># Create index for a collection.<br>milvus.create_index(collection_name=collection_name, index_type=IndexType.IVF_FLAT, params=ivf_param)</pre><p><strong>Insert and flush:</strong></p><pre># Insert vectors to a collection.<br>milvus.insert(collection_name=collection_name, records=vectors, ids=ids)</pre><pre># Flush vector data in one collection or multiple collections to disk.<br>milvus.flush(collection_name_array=[collection_name], timeout=None)</pre><p><strong>Load and search:</strong></p><pre># Load a collection for caching.<br>milvus.load_collection(collection_name=collection_name, timeout=None)</pre><pre># Search vectors in a collection.<br>search_param = { &quot;nprobe&quot;: 16 }<br>milvus.search(collection_name=collection_name,query_records=[vectors[0]],partition_tags=None,top_k=10,params=search_param)</pre><p><strong>Get collection/index information:</strong></p><pre># Return information of a collection.    milvus.get_collection_info(collection_name=collection_name, timeout=10)</pre><pre># Show index information of a collection.    milvus.get_index_info(collection_name=collection_name, timeout=10)</pre><p><strong>Get vectors by ID:</strong></p><pre># List the ids in segment<br># you can get the segment_name list by get_collection_stats() function.<br>milvus.list_id_in_segment(collection_name =collection_name, segment_name=&#39;1600328539015368000&#39;, timeout=None)</pre><pre># Return raw vectors according to ids, and you can get the ids list by list_id_in_segment() function.<br>milvus.get_entity_by_id(collection_name=collection_name, ids=[0], timeout=None)</pre><p><strong>Get/set parameters:</strong></p><pre># Get Milvus configurations.    milvus.get_config(parent_key=&#39;cache&#39;, child_key=&#39;cache_size&#39;)</pre><pre># Set Milvus configurations.    milvus.set_config(parent_key=&#39;cache&#39;, child_key=&#39;cache_size&#39;, value=&#39;5G&#39;)</pre><p><strong>Delete index/vectors/partition/collection:</strong></p><pre># Remove an index.    milvus.drop_index(collection_name=collection_name, timeout=None)</pre><pre># Delete vectors in a collection by vector ID.    <br># id_array (list[int]) -- list of vector id    milvus.delete_entity_by_id(collection_name=collection_name, id_array=[0], timeout=None)</pre><pre># Delete a partition in a collection.    milvus.drop_partition(collection_name=collection_name, partition_tag=partition_tag, timeout=None)</pre><pre># Delete a collection by name.    milvus.drop_collection(collection_name=collection_name, timeout=10)</pre><h3>Milvus and Google Colaboratory work beautifully together</h3><p>Google Colaboratory is a free and intuitive cloud service that greatly simplifies compiling Milvus from source code and running basic Python operations. Both resources are available for anyone to use, making AI and machine learning technology more accessible to everyone. For more information about Milvus, check out the following resources:</p><ul><li>For additional tutorials covering a wide variety of applications, visit <a href="https://github.com/milvus-io/bootcamp">Milvus Bootcamp</a>.</li><li>For developers interested in making contributions or leveraging the system, find <a href="https://github.com/milvus-io/milvus">Milvus on GitHub</a>.</li><li>For more information about the company that launched Milvus, visit <a href="https://zilliz.com/">Zilliz.com</a>.</li></ul><h4>Gain Access to Expert View — <a href="https://datadriveninvestor.com/ddi-intel">Subscribe to DDI Intel</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=536dc9b75301" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/set-up-milvus-in-google-colaboratory-for-easy-ml-application-building-536dc9b75301">Set Up Milvus in Google Colaboratory for Easy ML Application Building</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passing the Turning Point of AI Transformation]]></title>
            <link>https://medium.com/data-science/passing-the-turning-point-of-ai-transformation-4855bc9742a1?source=rss-e0ca89fe027------2</link>
            <guid isPermaLink="false">https://medium.com/p/4855bc9742a1</guid>
            <category><![CDATA[unstructured-data]]></category>
            <category><![CDATA[unstructured-data-service]]></category>
            <category><![CDATA[milvus-project]]></category>
            <dc:creator><![CDATA[Jun Gu]]></dc:creator>
            <pubDate>Wed, 12 Aug 2020 03:44:31 GMT</pubDate>
            <atom:updated>2020-08-13T05:38:10.915Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>How you would benefit from </strong><a href="https://milvus.io/"><strong>Milvus</strong></a><strong>, an open-source project for data scientists</strong></h4><p><em>When talking about the open-source AI projects, people would think of the model framework projects like Google TensorFlow, PyTorch, etc. Since the model framework is the critical component while training the AI models, those projects usually receive the most attention. But Artificial Intelligence (AI) is not a technology. AI is a complicated tech field involving several sub-areas and many different components.</em></p><p><a href="https://milvus.io/"><strong>Milvus</strong> </a>is an open-source project providing data serving functionality for the open-source AI ecosystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K3WEoqCJ--Gg7z5U" /><figcaption><a href="https://landscape.lfai.foundation/">The landscape of open source AI projects in different sub-areas</a> (<em>Image by author</em>)</figcaption></figure><h3>The turning point of AI transformation</h3><p>Generally speaking, the turning point of technology upgrades is the point where the returns of technology upgrades go far beyond the cost. When it applies to AI transformation, it would involve fundamental factors containing models (algorithms), model inference, and data service.</p><p>While talking about the models, we need to ask ourselves about the expectation of leveraging AI technologies. If we want to use AI technologies to beat and replace human workers, for example, to replace all the customer support specialists with the AI-powered conversational bot. Then the demands of the AI models will be pretty high and will not even be achievable in the short term.</p><p>If we want to alleviate our customer support specialists from the tedious daily routines, which means we intend to leverage AI technologies as an amplifier to improve human productivity and capability, then the models today are already good enough in many scenarios.</p><p>It sounds inspiring. However, one heated debate regarding models is that, although some models are available to the public, the best models (the state-of-the-art models, SOTA) are not. The companies which could hire AI scientists with the own those SOTA models. So would I lose the competitive advantage if I only use the public models?</p><p>People are scratching their heads over this because they assume models with greater effectiveness would deliver higher business value. Yet this could be wrong. In most cases, the relationship between model effectiveness and business value is neither linear nor monotonically increasing. The graph of the function should look like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*5pl23HL6x8jgMsBo-6k3VQ.png" /><figcaption>The relationship between model effectiveness and business value (<em>Image by author</em>)</figcaption></figure><p>It is a piecewise function. In the first phase, before the model is practical in the application scenario, there is no business value. In the second phase, although a better model theoretically should have better performance (response time, effectiveness, etc.), it could be not that obvious in the real world scenario. Let us take a look at the below circumstance.</p><p>Before a doctor could confirm if a patient has lung infections, the doctor needs to take the CT images of the suspicious patient’s lungs. It would generate around 300 CT images. And an experienced doctor would have to spend 5–15 minutes on studying these hundreds of CT images. Normally, it would not be a problem if a doctor only deals with a small number of patients. However, in extreme cases such as the COVID-19, doctors are overwhelmed by the surge of patients.</p><p>The good news is data scientists have tried to help doctors by the computer vision technology. They trained the models which could process the hundreds of CT images and provide diagnostic suggestions in seconds. Hence doctors only need to take 1 minute to review the results generated by the models.</p><p>So before applying machine learning technology, it would take an average of 10 minutes to review the results generated in one CT scan, now it would take about 1 minute. The productivity improvement is almost 90%.</p><p>What if we have a faster model which would only need 3 seconds to generate the results? From 1 minute and 5 seconds to 1 minute and 3 seconds, it does not seem attractive.</p><p>What if we have a more effective model that could raise the accuracy from 80% to 90%? Could doctors review fewer results? The answer is no because<strong>,</strong> although the model could only be wrong in 1 of 10, we could not know which one is incorrect. Thus the final reviewer has to go through all the results. As a result, it would not save more diagnostic time.</p><p>Furthermore, to lower the cost of the model inference service, we sometimes would rather sacrifice the model effectiveness. Here’s a real example from our user, they are a business intelligence platform that holds 55 million images of trademarks. The company wanted to provide a service that allows users to search the owners of these trademarks. Users perform the search by uploading trademark images as the input query instead of giving the keywords.</p><p>The technology behind is computer vision, for instance, the VGG model. If the company runs the model inference on the back end server, they have to allocate and reserve the hardware resources in the data center. Another choice is to deploy a smaller model so that the company could put the model inference on edge devices (the smartphone in most cases). It will certainly cut off the cost of the expensive model inference hardware like GPU. It is another example that SOTA models are impossible to be competitive in all the scenarios.</p><p>We are already at the turning point of AI transformation. Then the question is how we could pass the turning point and adopt the AI technologies to empower our business.</p><p>A usable model is a prerequisite. However, we would not be able to develop an AI program at ease if we only have the model. Like in the traditional applications, data serving is always a critical piece. And we can see it is becoming an essential component in AI adoption nowadays. That is why we initiated the open-source project-Milvus to accelerate AI adoption.</p><h3>The data challenge of AI adoption</h3><p>Most of the data we try to process through AI technologies is unstructured. We expect the Milvus project to provide a solid foundation for unstructured data service.</p><p>People usually categorize data into three types, structured data, semi-structured data, and unstructured data. Structured data includes numbers, dates, strings, etc. Semi-structured data usually comprises text information in certain formats, such as various computer systems logs. Unstructured data involves pictures, video, voice, natural language, and any other data that could not be directly processed by the computer.</p><p>It is estimated unstructured data accounts for at least 80% of the overall digital data universe. For example, you may send and receive several kilobytes text messages with your family, friends, or colleague every day. But even if you only take one photo on your mobile device, let’s say it’s iPhone 11 with a 12-megapixel camera, it would be several megabytes. And what if you take a video shot with 720p resolution?</p><p>People have developed technologies like relational databases, big data technologies to process structured data efficiently. And semi-structured data can be handled by the text-based search engine like Lucene, Solr, Elastic Search, etc. However, for unstructured data, the large chunk of all data, people didn’t have effective analytical methods in the past. Until the rise of Deep Learning technology in recent years, the development of unstructured data processing had been unthinkable.</p><h3>Unstructured data service</h3><p>Embedding, a Deep Learning jargon, refers to transforming unstructured data into feature vectors through the models. Since a feature vector is a numeric array, it’s easy to be processed by computers. Thus the analysis of unstructured data could be translated to vector computation.</p><p>One most common argument is feature vector seems to be the intermediate result in the unstructured data processing. Is it necessary to build up a general-purpose vector similarity search engine? Should it be included in the models?</p><p>From my perspective, a feature vector is not just the intermediate result. It is the knowledge representation of unstructured data in Deep Learning scenarios. It’s also known as feature learning.</p><p>Another argument is<strong>, </strong>since a feature vector also contains numerical values, why not perform vector computation upon existing data processing platforms like databases or computing framework such as Spark.</p><p>To be precise, a vector consists of a list of numbers. It leads to two significant differences between vector computation and numerical operations.</p><p>First, the most frequent operations of vectors and numbers are different. For numbers, addition, subtraction, multiplication, and division are the most common operations. But for vectors, the most common requirement is to calculate the similarity. You see, here I am giving the formula for computing Euclidean distance, and the computation of vectors is much higher than the ordinary numerical calculation.</p><p>Secondly, the index organization of the data is different. Between two numbers, we can compare the values with each other. So we could create the number index based on the algorithm like B tree. But between two vectors, we could not perform the comparison. We can only calculate the similarity between them. So the vector index is usually based on algorithms like approximate nearest neighbor ANN algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/0*SQ9_CgoDz5YyWufg" /><figcaption>A space partitioning algorithm (<em>Image by author</em>)</figcaption></figure><p>Because of these significant differences, we find it hard to meet the requirements of vector analysis with the traditional database and big data technologies. The algorithms they support and the scenarios they focus on are all different.</p><p>We are not reinventing the wheels in the Milvus project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pYQyoGCeLDlal75v" /><figcaption>The position of the Milvus project in a typical AI application (<em>Image by author</em>)</figcaption></figure><h3>To find out the use cases</h3><p>Links of use cases:</p><ol><li><a href="https://medium.com/unstructured-data-service/milvus-application-1-building-a-reverse-image-search-system-based-on-milvus-and-vgg-aed4788dd1ea?source=friends_link&amp;sk=f4253bd304674ba24dc14c5424ea8aef">Milvus × VGG: Building a Content-based Image Retrieval System</a></li><li><a href="https://medium.com/unstructured-data-service/smarter-housing-search-and-recommendation-powered-by-milvus-66cb0d201e7e?source=friends_link&amp;sk=616944da30ddda4ba08d5b06faf22353">Smarter Housing Search and Recommendation Powered by Milvus</a></li><li><a href="https://medium.com/unstructured-data-service/milvus-in-action-chemical-structure-similarity-search-33130767162a?source=friends_link&amp;sk=b1e4f1100bd480f63f56eee368e17dd2">Accelerating New Drug Discovery</a></li></ol><h3>Join the open-source community</h3><p>The Milvus project is an incubating project hosted by the <a href="https://lfai.foundation/projects/milvus/">LF AI foundation</a>.</p><p>Please feel free to <a href="https://medium.com/unstructured-data-service/join-our-open-source-community-4ab0693baa9f?source=friends_link&amp;sk=a1a8a8ac82787c77d72f224b87f070b0"><strong>join the community of the Milvus project</strong></a><strong>.</strong> If you are interested in the Milvus project, want to build up AI applications upon it, or would like to engage in the project development.</p><p>If you want to learn more detail about the project, please follow the publication <a href="https://medium.com/unstructured-data-service"><strong>Unstructured Data Service</strong></a>.</p><h3>About the author</h3><p>I am <a href="https://www.linkedin.com/in/gujun720/"><strong>Jun Gu</strong></a>, a database engineer and one of the enthusiastic organizers of the Milvus open-source community.</p><p>I am currently a member of the technical advisory council (TAC) at the LF AI foundation. However, my longest working experience was in the Fin-tech domain. I served in the Enterprise Infrastructure Dept. of Morgan Stanley for 8 years.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4855bc9742a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/passing-the-turning-point-of-ai-transformation-4855bc9742a1">Passing the Turning Point of AI Transformation</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The missing piece towards ‘any scale’ spatial-temporal analytics]]></title>
            <link>https://medium.com/data-science/the-missing-piece-towards-any-scale-spatial-temporal-analytics-2677063d95e3?source=rss-e0ca89fe027------2</link>
            <guid isPermaLink="false">https://medium.com/p/2677063d95e3</guid>
            <category><![CDATA[geopandas]]></category>
            <category><![CDATA[postgis]]></category>
            <category><![CDATA[arctern-project]]></category>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jun Gu]]></dc:creator>
            <pubDate>Mon, 15 Jun 2020 07:42:16 GMT</pubDate>
            <atom:updated>2020-06-23T12:48:31.052Z</atom:updated>
            <content:encoded><![CDATA[<h4><a href="https://towardsdatascience.com/data-science-in-the-real-world/home">Data Science in the Real World</a></h4><h3>The Missing Piece towards ‘any scale’ Spatial-temporal Analytics</h3><h4>Why we created Arctern project</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jluxmUgMLg1DCN3TDnvgcQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@sidverma">Sid Verma</a> on <a href="https://unsplash.com/photos/6usLW9odNjY">Unsplash</a></figcaption></figure><p>Internet of Things (IoT) and 5G technologies will involve an astounding amount of data recording the links between people, device, event, location, and time. According to IDC’s forecast, there will be 79.4 zettabytes of data generated by 41.6 billion IoT devices in 2025. With the rapid growth of IoT data and IoT applications, there is an ever rising demand for a highly efficient spatial-temporal data science workflow to gain insights from the overwhelming data.</p><p>Scalability is key to building productive data science pipelines. To address this scalability challenge, we launched Arctern, an open source spatial-temporal analytic framework for boosting end-to-end data science performance. Arctern aims to improve scalability from two aspects:</p><ol><li>Unified data analytic and processing interface across different platforms, from laptops to clusters and cloud;</li><li>Rich and consistent algorithms and models, including trajectory processing, spatial clustering and regression, etc., across different data science pipeline stages.</li></ol><p>The rest of this article probes into the current geospatial data science pipelines and reviews the tools, libraries, and systems used in each stage. By discussing the existing workflows’ deficiencies, we underscore the importance of scalability. We will show that well-scaled interfaces, algorithms, and models not only reduce the time to solve mathematical or technical problems, but also improve the efficiency of collaboration and communication between data scientists and engineers.</p><h3>A brief review of spatial-temporal data science workflows</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VbHO9IMqDS1xgorK.png" /><figcaption>Image by author</figcaption></figure><p>To better understand the scalability problem existing in the current workflows, we need to take a look at the pipeline of spatial-temporal data science, which is illustrated in the figure above. Raw data is first generated by IoT devices, and then collected by data store. Data scientists make exploratory analysis over these data. Basing on technical hypothesis and data features, they select proper models to develop a prototype for answering business questions. After a few iterations of evaluation and adjustment, the model will finally be deployed on a data processing system, which in turn delivers better services to end users via IoT devices.</p><p>The whole process can break down to three stages:</p><ul><li><strong><em>Prototype development</em>.</strong> In this stage, data scientists tend to work with small datasets for the purpose of fast data exploration, efficient model selection, and iterative prototype polishing. Lightweight tools are favored in this stage, because they can provide quick insights and support fast iteration. Typical tools include NumPy, GeoPandas, scikit-learn, PySAL, and kepler.gl.</li><li><strong><em>Model evaluation</em>.</strong> To fit the prototype into the production environment, much larger (or even close to production level) datasets are used for model evaluation. As a result, the model evaluation-modification iterations in this stage are much less agile than in the prototype stage. Moreover, the tool chain is much heavier. Most of the commonly-used tools, such as PostGIS and PySpark, are disk-based, or distributed.</li><li><strong><em>Model deployment</em>.</strong> Deployment is the stage where the model is integrated into the existing production environment to provide practical services. This stage involves large-scale systems such as HDFS, Hbase, TSDB for storage, and Spark, Flink, GeoMesa for data processing.</li></ul><h3>The scalability problems</h3><p>At different stages of spatial-temporal data science, demand for tool chain varies significantly. Although libraries and systems mentioned above can jointly support the overall data science workflow, an individual tool can hardly scale across multiple data science stages or across different analytic platforms (laptop, cluster, or cloud). As a result, the tool chain grows increasingly complex to a point where it is hard to streamline the workflow. Specifically speaking, the challenges are three-fold:</p><ul><li><strong><em>The gap between library (system) interfaces</em>.</strong> Libraries or systems used in different stages do not share a unified interface. As a consequence, data scientists may use multiple languages such as Python, R, Scala, SQL and inconsistent function names throughout the process of data analysis, prototype development, model evaluation, and model deployment. Such interface inconsistency significantly steepens the learning curve, and forces data scientists to spend valuable time and brainpower rewriting their codes, rather than focusing on business questions.</li><li><strong><em>The gap between algorithm/model libraries</em>. </strong>Libraries used in different stages have different support for algorithms and models. At present, the agreement of standardization is still on the level of primitives, as the ones proposed by the Open Geospatial Consortium (OGC). This significantly reduces productivity. When an advanced algorithm is used as part of the solution during prototype development, but no proper implementation is found for the production environment, great efforts have to be taken to reinvent the wheel.</li><li><strong><em>The gap between data scientist and engineer</em>. </strong>Spatial-temporal data science is a complex area where mathematical problems, technical problems, and business problems need to be properly handled. It calls for seamless collaboration between data scientists and engineers. However, the inconsistency of the tools used throughout the workflow makes collaboration difficult. Given that different programming languages and algorithm implementations are used in different data science stages, the engineers may have no idea as to what models the data scientists used, whilst the data scientists are struggling to understand why the engineers cannot make their models work.</li></ul><p>In the next few sections, we will compare several libraries and systems widely used in spatial-temporal data science, and give more discussion on the missing piece towards ‘any scale’ spatial-temporal analytics.</p><h3>Popular tools and their limitations</h3><p>As Python is becoming the primary solution for geospatial data processing and analysis, data scientists have developed a vocabulary based on a tool set including NumPy, Pandas, Shapely, GeoPandas, PySAL, etc. With these tools, they can fully express their thoughts and follow an idea to its conclusion.</p><p>Shapely is a Python package providing primitives such as geometric data construction, common geometric operations, relationship analysis and coordinate system projection. GeoPandas combines the capabilities of Pandas and Shapely to ease geospatial data processing in python. It organizes geospatial data as GeoSeries or GeoDataFrames and provides operations to construct, analyze, and manipulate multiple geometries.</p><p>PySAL is a Python spatial analysis library that provides modules for higher-level analysis on geospatial data. Its functionality includes spatial data exploratory analysis like statistical testing on points, polygonal lattices as well as advanced spatial analysis, such as spatial clustering and spatial regression.</p><p>Despite their popularity, these tools cannot scale to crunch big data. They were inherently designed for small datasets on a standalone machine. Considering the capacity of modern laptops and workstations, the size of data that these tools can handle would be up to a couple of GBs. The figure below shows the performance of 19 frequently-used primitives in GeoPandas. As we can observe, when data size reaches 10M, most of the primitives in GeoPandas take several minutes to complete. PySAL shares the same problem with GeoPandas when handling large datasets. Compared with the primitives in GeoPandas, the advanced algorithms in PySAL generally have higher computation complexity, thus may cause even severer efficiency problems on data analysis and prototype development. Since data scientists need to iteratively adjust and verify their models until they get satisfying results, these primitives and algorithms are frequently and repeatedly used. The scalability problem would seriously degrade efficiency in the spatial data science workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vyAARq_oJa2zm7cu.png" /></figure><p>Due to the scalability problem, the above-mentioned tools are generally used in prototype design with small datasets. To work with large production-level datasets, data scientists and engineers would eventually need to migrate their algorithms to distributed solutions, such as GeoSpark and GeoMesa.</p><p>GeoSpark is a cluster computing system that extends Apache Spark and SparkSQL with a set of Spatial Resilient Distributed Datasets and SpatialSQL functions that efficiently load, process, and analyze large-scale spatial data across machines. GeoMesa enables large-scale geospatial query and analytics on distributed computing systems, including spatial-temporal indexing, stream processing, and custom distributed analytics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*1ZKUsii6AM4DxVaiRPXN9Q.png" /></figure><p>Compared with GeoPandas and PySAL, GeoSpark and GeoMesa adopt very different API abstraction. The Table above presents an interface comparison. The data interfaces vary greatly among different tools, with no pair of tools sharing identical data interface. In terms of programming language, there are three major categories: python, SQL, and Java/Scala.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*WIWsPG9vewNa0d-ks6yjHg.png" /></figure><p>The table above compares the provided primitives and algorithms among geospatial analysis tools. The number of supported OGC standard primitives shows large difference, ranging from around 30 to three hundred. The advanced algorithms show great divergence as well. Each of the tools offers a limited set of algorithms that hardly overlap.</p><p>Due to the significant inconsistency in data interface, programming language, algorithm, and model, whenever applying a model prototype to large production datasets, engineers may have to rewrite the entire data processing logic. For advanced analysis such as spatial clustering and regression, data scientists may have to re-implement models and algorithms from scratch.</p><h3>Arctern’s approach and current progress</h3><p>In Arctern, to help data scientists and engineers improve productivity and creativity, we try to fix the inconsistency problem of spatial data science tools by providing rich primitives, algorithms, and models with consistent interfaces across laptop, cluster and cloud environments.</p><p>Among the tools we studied, we found that GeoPandas has interfaces working best with the usage habits of data scientist and is easy to use. Therefore, we adopt its idea and plan to build the GeoDataFrame/GeoSeries that scale both up and out. On top of this, we will develop a consistent spatial-temporal algorithm set across execution environments.</p><p>We have now developed an efficient multi-thread GeoSeries implementation, and the distributed version is in progress. In the latest version 0.2.0, Arctern achieves 24x speed up against GeoPandas. Even under single-thread execution, Arctern outperforms GeoPandas 7x on average. The detailed evaluation results are illustrated in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FUquKhqbvP94AACb.png" /></figure><p>In terms of interaction/exploration on large datasets, Arctern provides rendering methods that can render data (as heatmap, choropleth, etc.) with a volume of 10M in seconds.</p><p>We are also conducting experimental GPU acceleration for spatial-temporal data analysis and rendering. By now Arctern provides six GPU-accelerated rendering methods and eight spatial-relation operations, which outperform their CPU-based counterparts with up to 36x speed up.</p><p>In the next few releases, our team will focus on:</p><ul><li>Developing a distributed version of GeoSeries. Our first distributed implementation of GeoDataFrame/GeoSeries will be based on Spark. It is developed in sync with Spark 3.0 since its preview release. Spark’s supports on GPU scheduling and column-based processing is highly in line with our idea of high-performance spatial-temporal data processing. Besides, the introduced Koalas interface offers a promising option for implementing consistent GeoDataFrame/GeoSeries interfaces.</li><li>Enriching our spatial-temporal algorithm sets. We will concentrate on KNN search and trajectory analysis in the project’s early stages.</li></ul><p><strong><em>Learn more about Arctern：</em></strong><a href="https://github.com/arctern-io"><em>https://github.com/arctern-io</em></a></p><h3>About the Authors</h3><p><strong>Rentong Guo</strong> is a Director of R&amp;D of Arctern project. He received a Ph.D. degree in Computer Software and Theory from Huazhong University of Science and Technology (HUST), China. He spends his career participating in and leading projects in the area of database, cache system, distributed system, and heterogeneous computing.</p><p><strong>Xiaomeng Yi </strong>is a senior researcher of Arctern project. Xiaomeng Yi received his Ph.D. degree in Computer Architecture from Huazhong University of Science and Technology. His research focuses on scheduling and resource allocation in the cloud and distributed systems. His works are published in prestigious conferences and journals, such as IEEE Network Magazine, IEEE TON, IEEE ICDCS, and ACM TOMPECS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2677063d95e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/the-missing-piece-towards-any-scale-spatial-temporal-analytics-2677063d95e3">The missing piece towards ‘any scale’ spatial-temporal analytics</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>